user3066958
user3066958

Reputation: 1

solr : search results only docs which have a value in a specific field

I have these fields in schema.xml :

<field name="type" type="string" indexed="true" stored="true"/>
<field name="id_boutique" type="string" indexed="true" stored="true"/>
<field name="nom" type="text_full" indexed="true" stored="true" omitNorms="false"/>
<field name="nom_boutique" type="string" indexed="false" stored="true"/>
<field name="categorie_nom" type="string" indexed="false" stored="true"/>
<field name="description" type="text_full" indexed="true" stored="true"/>
<field name="detail" type="text_full" indexed="true" stored="true"/>
<field name="url" type="string" indexed="false" stored="true"/>
<field name="logo" type="string" indexed="false" stored="true"/>
<field name="logo_boutique" type="string" indexed="false" stored="true"/>
<field name="textng" type="autocomplete_ngram" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true" omitNorms="false" />

I would like to get, as search results, only docs which have a value in the field "logo". Note that I use this config :

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">textng</str>
<str name="defType">edismax</str>
<str name="rows">100</str>
<str name="fl">*,score</str>
<str name="qf">textng logo^5</str>
<str name="sort">type asc, score desc</str>
<str name="pf">textng^100</str>
<double name="typeboost">1.0</double>
<str name="debugQuery">false</str>
</lst>
<arr name="first-components">
<str>spellcheck</str>
</arr>
</requestHandler>

Any help is appreciated.

Upvotes: 0

Views: 139

Answers (1)

Aujasvi Chitkara
Aujasvi Chitkara

Reputation: 939

To pull results where logo field has some value, you can add a filter query to your search. It will look something like:

http://localhost:8080/select/?q=*:*&fq=logo:["" TO *]

or if you want to do it in your request handler above, it would look like:

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">textng</str>
<str name="defType">edismax</str>
<str name="rows">100</str>
<str name="fl">*,score</str>
<str name="qf">textng logo^5</str>
<str name="fq">logo:["" TO *]</str>
<str name="sort">type asc, score desc</str>
<str name="pf">textng^100</str>
<double name="typeboost">1.0</double>
<str name="debugQuery">false</str>
</lst>
<arr name="first-components">
<str>spellcheck</str>
</arr>
</requestHandler>

Note: I have added <str name="fq">logo:["" TO *]</str> to your request handler.

Upvotes: 1

Related Questions