Question

I am new to solarium and i am using version 2. I have created the schema, and i need to know on how to pass the search key which should search in all fields OR few fields as per the xml.

Ex : my fields as something like this. "title", "description", "keywords" etc. So when user types some word as "xyz" it should search in all the above mentioned fields and result me the output. It should search not only has exact but it should be something like our sql "like"

The solarium sample examples didn't come up handy.

Any help appreciated.

EDIT _ FIELDS USED

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    -->
    <filter class="solr.LowerCaseFilterFactory"/>

All my fields type is text_general.. I use solr 4.2.1

Was it helpful?

Solution

You can configure your schema.xml to

  1. Use copyfield to combine title, description, keywords into a single field, and then search on that field.
  2. Use EdgeNGramFilter filter to break the works into fragments so as to match the sql like behaviour.

e.g.

<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="25" />
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>


<field name="all_fields" type="text" indexed="true" stored="false" multiValued="true"/>

<copyField source="title" dest="all_fields"/> 
...............
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top