English 中文(简体)
Lucene.Net Search List
原标题:

I m using Sitecore and have a multilist field I d like to use Lucene to search on. The problem I have is that the field is a pipe-delimited list of actual values and there could be between 0 and an infinite (theoretically speaking, actually there s probably only a thousand or two possibilities) number of items in this list. I haven t been able to successfully use a wildcard query and I can t envision how to break this field up into multiple fields since there s an unknown number of items in the list.

最佳回答

I ve used a similar technique in searches to search within a category heirarchy. I use the following method to build the query, leaving the hard work to the QueryParser class. I usually add this query to a BooleanQuery.

The QueryParser usually does a great job, I often use it for building most of my Lucene queries - it seems to do a better job than me when building a specific query a lot of the time!!

Another thing you can do is to use the QueryParser to build it, then set a breakpoint and have a look at how the query has been created, then update your code with the specific query type.

private Query GetQuery(Sitecore.Data.ID id)
{
    string categoryId = id.Guid.ToString(); //turn ID to string
    StandardAnalyzer analyzer = new StandardAnalyzer(); //use standard analyzer
    QueryParser parser = new QueryParser("categories", analyzer); //search inside category field
    Query query = parser.Parse(categoryId); //get the query
    return query;
}
问题回答

暂无回答




相关问题
How do I hook the Save event in Sitecore Page Editor?

I m creating a custom edit control for my content authors to use in the Page Editor. Of course this means I want my control to save data to an Item when the user clicks on the Save button. How is ...

Passing Parameters to a Sitecore Sublayout

I ve done this before with a web control, but I can t seem to get it to work with a sublayout. On the Presentation Details for a particular item I m assigning my Sublayout and then in the additional ...

Lucene.Net Search List

I m using Sitecore and have a multilist field I d like to use Lucene to search on. The problem I have is that the field is a pipe-delimited list of actual values and there could be between 0 and an ...

Test for Descendant Items

I am trying to create a simple inventory of items in a Sitecore website using an xslt. The problem is that I can t find a way to test whether an item has descendant items beneath it. It s easy to ...

Sitecore set/change default language from en

Can anyone recommend the best way to change the default language in Sitecore 6.1. On a fresh install, the typical language for all items is en English, witha nice little USA flag and all. However, ...

热门标签