I am using Solr 6.0.0
I am tring to filter out unwanted suggestions from Solr Suggester. In my Solr database I have all my products
My products all have a boolean field "ShowOnSite". Products that are ready for sale have this value set to true. Products not yet ready have it set to false.
When I try to filter the suggested results from the suggester using this boolean field, I always get 0 results, even though I have plenty of products ready to be shown.
My Products looks somewhat like this like this:
<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="Name" type="string" indexed="true" stored="true"/>
<field name="ShowOnSite" type="boolean" indexed="true" stored="true" />
<field name="text_autocomplete" type="textSuggest" indexed="true" stored="true"/>
The textSuggest fieldType has the following configuration:
<fieldType class="solr.TextField" name="textSuggest" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
My suggester looks like this
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">20</str>
<str name="wt">json</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">default</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str>
<str name="highlight">true</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">text_autocomplete</str>
<str name="weightField">InStock</str>
<str name="contextField">ShowOnSite</str>
<str name="suggestAnalyzerFieldType">textSuggest</str>
<str name="buildOnStartup">true</str>
</lst>
</searchComponent>
My query looks like this:
/suggest?suggest.q={querystring}&suggest.cfq=true
Expected I receive only the products that has "ShowOnSite" == true
Actual I receive 0 proucts from the suggester
I have tried other configurations aswell. By using not true I get all products:
/suggest?suggest.q={querystring}&suggest.cfq=-true
I have also tried to add the field name in the cfq. This yields 0 products:
/suggest?suggest.q={querystring}&suggest.cfq=ShowOnSite:true
EDIT1 I have also tried using either 0 or 1 for false and true respectively. These do not work either
cfq
. Try with0
, or better; make a secondary field as a string field and store thefalse
ortrue
value verbatim in that field - and try filtering by that instead. – MatsLindhtrue
is sent back to the index as the token (no analysis etc. taking place), it doesn't match what token is actually stored. You can go deeper into this by looking at what has been actually stored in the index for that field andtrue
/false
values. But as I said, this is a guess. It might be wildly wrong. – MatsLindh