Search code examples
javasolrlucenesolr-query-syntax

Solr query syntax such like SQL “IN” condition


A Solr query problem here.

For example, a group checking query: There’s a string spitted by commas field in Solr, such as “Group1, Group2, Group3”. I have parameter which is a list of string, such as “Group3”, “Group4”, “Group5”. In this case the document with “Group1, Group2, Group3” need to be retrieved, because “Group3” is contains in the field.

It’s like SQL “IN”, but I don’t find a way to query such conditions. The problem is Solr doesn’t allow wildcard as first query.

Any solution for this problem? Thanks a lot!


Solution

  • Did you make sure the type of the column you are using in your schema is:

    <fieldType name="text_country" class="solr.TextField" positionIncrementGap="100">

    and not:

    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>