问题
I just got started looking at using Solr as my search web service. I don't know whether Solr supports these query types:
- Startswith
- Exact Match
- Contain
- Doesn't Contain
- In the range
Could anyone guide me how to implement those features in Solr?
Cheers, Samnang
回答1:
Solr is capable of all those things but to adequately explain how to do each of time an answer would become a mini-manual for Solr.
I'd suggest you read the actual manual and tutorials linked from the Solr homepage.
In short though:
Startswith can be implemented using Lucene wildcards.
Exact matches will only be found if a field is not tokanized. I.e. the entire field is viewed as a single token.
Contain is the default search format. I.e. a search for "John" will find any document's whose search field contains the value "John". Prefixing with - (e.g. "-John" will only find documents that do not contain John).
Ranges (be they date or integer) are possible and quite powerful, example date:[* TO NOW] would find any document whose date is not in the future.
回答2:
Samnang, please try the SolrQuerySyntax page in the Solr Wiki.
回答3:
You can also find interesting infos on Solr query syntax here: http://www.solrtutorial.com/solr-query-syntax.html
来源:https://stackoverflow.com/questions/968504/solr-query-syntax