Closed cherrydev closed 10 years ago
Can you provide sample code that would construct a multi-term query using a list of values?
I'm not sure how to implement this. If you have suggestions, feel free to reopen.
Ya, I tried to fuss around with this to get some sort of efficient implementation, but it appears that Lucene is simply terrible at this particular use-case. The naive implementation of constructing a long string of 'or' terms actually performs terribly on any field that has a cardinality of n (a unique field). The fastest implementation I settled on was to sort the terms, open a termdocs() on the first term, get the docID(s) and then seek to the next, etc. I don't see how that implementation could be generalized for use in Lucene.Net.Linq though.
If I try to do
queriable.Where(x => listOfValues.Contains(x.Value))
I get an exception:I wonder if there's a way to special-case this into a multi-term query, which should run efficiently in Lucene (although subject to the term limit, of course).