views:

3393

answers:

3
+1  Q: 

Solr Query Syntax

Hi all,

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

+3  A: 

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.

Kris
+1  A: 

Samnang, please try the SolrQuerySyntax page in the Solr Wiki.

Yuval F
A: 

i have create a schema, one of field contains text. i want to do Contain operation. how can i do.

filed name is description.

Thx Raj

raj
This site is not a message forum, please take a couple of minutes to read the FAQ, then delete this answer and post a new question instead.
Mauricio Scheffer