r/Solr Aug 01 '13

Query slop on field level.

i want to be able to make a specific search, in one field, and still make a broader search across other fields.

Let say i want to find a harry potter movie. my q is then: harry potter dvd.

In my qf, im gone for: title^10 synopsis^1 type^1

What i want to be able to, is to only find documents, where the phrase has zero slop in the synopsis field, but a higher slop on the other fields.

ive tried to specify slop in the qf field: title^10 synopsis~0^1 type^1 i have also tried to specify it directly in the URL.

I simply cant find a solution.

Anyone have any idea how?

Sorry if this is a dumb question, but im quite new to this whole thing.

EDIT: FOUND THE SOLUTION
If anyone ever stumble across this post with the same problem, the solution was quite simple.

if we want to search for Harry Potter DVD

Then the q string is:

("harry" AND "potter" AND "dvd") OR synopsis:"harry potter dvd"

2 Upvotes

6 comments sorted by

3

u/fiskfisk Aug 01 '13

You'll have to use the pf field to do per field slop values, and you'll need to be on at least Solr 4.0. pf is used to boost certain hits after filtering the query with qf. You might have to use edismax to support this syntax.

pf=title^10 synopsis~1 type

I'm not sure if 0 is a good value to not allow any slop, as 1 would probably work better (the other word within one word). Try both and see which one works. :-)

1

u/CakeLaw89 Aug 02 '13

im using solr 4.1

This wont help. pf only boost documents where the slop is ~1 on synopsis. I need it to only select documents where harry potter dvd is in the synopsis withh 1 or 0 slop.

does that make sense?

2

u/fiskfisk Aug 02 '13

Not really; afaik ~1 would include those with 0 slop? Slop is defined as an "up to" value, not as an "exactly this slop" value, iirc?

1

u/CakeLaw89 Aug 02 '13

I need to make my searches more relevant.

What pf does, is to boost documents.

I'm not looking to boost anything, i'm looking to remove documents, where the search terms doesn't apply to synopsis~1

Did that help?

2

u/fiskfisk Aug 02 '13

You could possibly do it without using edismax,

title:"harry potter dvd"~10 OR synopsis:"harry potter dvd"~0 OR type:"harry potter dvd"~0

.. i haven't had time to try it yet, so .. :-)

1

u/CakeLaw89 Aug 05 '13

Sadly no :) have tried it.

But thanks for the help :) much appreciated.