Reputation: 1171
I want to know if we can search an array of values for one field in Lucene?
For example:
String s[] = {"John","Daniel", "Doe"---------------------------until 50 or 1000};
All the string values are for FirstName field. Is it possible to search for multiple values in one field without making the operation expensive?
Thanks.
Upvotes: 2
Views: 4367
Reputation: 6144
You can just do,
fieldName: John Daniel Doe ...
All terms will be OR
ed, so the result set will contain all documents that matched any of the values.
The code to generate such query can be,
var nameValues = new[] { "John", "Daniel", "Doe", ... };
var query = new QueryParser(currentVersion, fieldName, analyzer)
.Parse(string.Join(" ", nameValues))
Upvotes: 2