Problems encountered in recent projects: Lucene. NET and monorail

Source: Internet
Author: User
1. Lucene. net returns the query set
Sometimes, you do not need or cannot use hits. DOC (I). Get ("ID") to read data. In this case, you can return a set.

Hits hits = NULL;
//...... The booleanqueryCode
// Ordervalue sorting, positive inverted reverse
Hits = Isearch. Search (Bq, new sort (New sortfield (ordervalue, sortfield. Doc, reverse )));

// Obtain the hititerator object, which inherits the ienumerator interface and is located under Lucene. net. Search.
Hititerator iters = hits. iterator ();

Method
Public Virtual Object current {Get;} // current hit
Public Virtual int length (); // set length
Public Virtual bool movenext (); // whether to move to the next hit
You can download the source code for details.


string IDs = "";
for (INT I = 0; I {< br> If (iters. movenext ()
{< br> hit H = hits. current as hit;
If (classids. contains (H. get ("ID")
continue;
IDs + = H. get ("ID") + ",";
}< br> else
break;
}

It can also be used in a list <Object> (the project uses monorail, so this method is mainly used)
List <Object> temphit = new list <Object> ();
For (INT I = 0; I <this. Hit. Length (); I ++) // looping hititerator set
{
// Determine whether the hititerator set ends
If (this. Hit. movenext () & index <= 1000)
{
Temphit. Add (this. Hit. Current );
}
Else
Break;
}

One advantage of this is that the monorail front-end is more convenient to call, and the other is that there are multiple searches for a single site, such as news and shopping malls. The front-end can call a method.

2. Question about passing Chinese characters to monorail URLs

Create a test project by yourself and enter http: // localhost/home/test. aspx in the address bar? Key = test

Put it in IIS, rewrite the URL to remove home, http: // localhost/test. aspx? Key = test

The webpage will output garbled characters, whether you add <globalization requestencoding = "gb2312" responseencoding = "gb2312" Culture = "ZH-CN" fileencoding = "gb2312"/> or nvelocity. properties is useless.

The reason is monorail's routing. The specific source code is not checked.

Because it is necessary to pass Chinese characters when Ajax is required, because it only modifies the routing regular and changes it to/SO/([^ Home]) (. *) in this way, the address with home is like http: // localhost/home/test. aspx? Key = test, will not pass the regular expression, monorail will not process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.