0

I'm implementing solr search using solr 4.9.0.

I want solr to return the result which match all of my query keywords not just one or few.

Let me put up the schema before giving up an example

<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="title" type="text_general" indexed="true" stored="true" required="true"/>
<field name="at" type="string" indexed="true" stored="true" required="true"/>
<field name="rt" type="custom1" indexed="true" stored="true" required="true"/>
<field name="st" type="custom1" indexed="true" stored="true" required="true"/>

i have a copyField for all of these (if that matters in case)

<copyField source="id" dest="text"/>
<copyField source="title" dest="text"/>
<copyField source="at" dest="text"/>
<copyField source="rt" dest="text"/>
<copyField source="st" dest="text"/>

and the "custom1" filedType, i have defined it as follows:

<fieldType name="custom1" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory" />
  </analyzer>
</fieldType>

The fieldType might not make some sense as I was trying a lot if combinations to get the results I want.

the fields could have the following values:

Title - could contain anything at - Room for girls, Condo for Singles, Co-aid hostel rt - 1 sharing, 3 sharing, single seater st - 1 BHK, 3 BHK

Now, if i query for "1 BHK flat in roselum city", I expect result only with st as "1 BHK" and other results containing the keywords in title.

But I'm also getting results with rt = "1 sharing" and also results having st = "3 BHK" as my query contains 1 and BHK and it matches everything containing any of these i.e.; either "1" or "BHK" or any other keyword in the query which is what i don't want.

I searched for related questions and found some hopeful answers but none worked:

Here's what I have already tried:
1. Performing EXACT match on SOLR search This answer totally matches my problem but I'm not able to do it even after following every step.
2. I have added <solrQueryParser defaultOperator="AND"/> to my schema.xml to force the query follow a AND rule but it didn't work either.
3. Added <str name="mm">100%</str> to my solrConfig.xml in "/query" requestHandler to match 100% of the keywords but that that also left me hopeless.

What I want is almost equal to what has been cited by fredseagul (first point) in his question.

Any expert who can elaborate the whole thing, please intervene.

Note: I want all this only by modifying the schema/any other config, don't want to make complex queries. Only the result having all the keywords in st or rt or at fields should get returned. title field is an exception, if any one of the keyword in query matches the title keyword, that result should be returned.


Please don't mark it duplicate. I have searched a lot for it.

Community
  • 1
  • 1
Shubham
  • 97
  • 1
  • 14

1 Answers1

1

You have a bunch of problems here:

  1. Your custom1 field definition is completely broken. Currently if you have an upper case word in the text with custom1 definition, it will never be matched because only lower-case words will ever match. You should use Analyze tab in the Admin WebUI to see what the definitions do.
  2. But this may not matter because you are doing copyField and probably searching on 'text' field as default. Which means only the type for the field text matter.

I'd recommend stepping back and doing some exercises/tutorials first. Most likely you want to use eDismax with list of fields and mm=100%. And no copyText.

Alexandre Rafalovitch
  • 9,709
  • 1
  • 24
  • 27