0

Solr newbie here

I am constructing queries to boost certain items on my webpage, and I want to be able to boost fields that contain a thumbnail (image) value:

<doc>
<str name="campaign"/>campaign
<str name="productclass">B</str>
<str name="thumbnail">
HPMAssets/d120001/derivates/1/250/103/005358625_121203_080900_9853_thumb.jpg
</str>
</doc>

For instance in the above, "thumbnail" contains a value and should therefore be displayed higher up on the search result page. I have tried:

q=(thumbnail:["" TO *])^99        (all non-empty thumbnails)
q=(-thumbnail:[* TO *])^99       (all non-null thumbnails)
q=(thumbnail:*)^99                (all thumbnails)

But it doesn't work. I know for a fact that I can boost values:

(campaign:campaign)^99 

Works and will display articles with 'campaign' (that is to say, items/articles with a special offer) first on the resulting page.

Why doesn't this work for thumbnails? How do I formulate a Solr-query so that it displays articles with an existing thumbnail before articles without an existing thumbnail?

EDIT

As MatsLindh correctly pointed out,

q=(-thumbnail:[* TO *])^99

Means all documents without a thumbnail and not all non-null thumbnails, which would be:

q=(thumbnail:[* TO *]).

Jazzbaron
  • 75
  • 11
  • Please don't misuse tags -- there's nothing in this question related to [boost](http://stackoverflow.com/tags/boost/info). – Dan Mašek Feb 23 '17 at 14:11
  • Apologies. I meant to use "Boosting", wrote the question a bit too hasty. – Jazzbaron Feb 23 '17 at 14:39
  • 1
    `q=(-thumbnail:[* TO *])^99` means all documents without a thumbnail - `thumbnail:[* TO *]` would be all documents with the field present. Have you tried moving the boost to a separate clause with `bq` and looking at what the output from `debugQuery=true` says? – MatsLindh Feb 25 '17 at 20:43
  • That was the first thing I tried, having a bq clause, which for some reason did not work. Anywho, I solved the problem by checking my schema.xml and changing the indexed value for thumbnail to true, whereby I re-indexed my whole schema to make the changes apply (see my answer to this post). The bq clause never worked for anything. – Jazzbaron Feb 27 '17 at 07:32

1 Answers1

0

Apparently, the problem was that thumbnails were not being indexed in my schema.xml:

 <field name="thumbnail" type="string" indexed="false" stored="true"  multiValued="false"/>

So I changed the "indexed" value to "true" and then re-indexed my whole schema. There was never anything wrong with the query-syntax.

Hope this helps any lost Solr soul in the future.

Jazzbaron
  • 75
  • 11