You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Luca Dall'Osto <te...@yahoo.it.INVALID> on 2017/07/17 10:20:23 UTC

Get results in multiple orders (multiple boosts)

Hello,
I'm new in Solr (and in mailing lists..), and I have a question about querying contents in multiple custom orders.
I 'm trying to query some documents boosted by 2 (or more) fields: I'm able to make a search of 2 day and return results boosted by category field, like this:

?indent=on
&defType=edismax
&q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z]) 
&bq=category:9500^2
&bq=category:1100^1
&rows=40
&wt=jsonThis will return all documents of category 9500 first, and 1100 in after.Now I would like to get this documents with a second boost based on another field, called source.I would like to have documents in this order:1) category:9500 AND source:5
2) category:9500 AND source:9
3) category:9500 AND source:7
4) category:1100 AND source:5
5) category:1100 AND source:9
6) category:1100 AND source:7
To get this order, I tied with this query:?indent=on
&defType=edismax
&q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z]) 
&bq=category:9500^2+source:(5^3 OR 9^2 OR 7^1)
&bq=category:1100^1+source:(5^3 OR 9^2 OR 7^1)
&rows=40
&wt=json
How can I apply a double boosts to get the documents in my correct order? Is boost the correct tool for my purpose?Any help will be greatly appreciated. Thanks
Luca

Re: Get results in multiple orders (multiple boosts)

Posted by Erick Erickson <er...@gmail.com>.
I don't think boosting is really what you want here. Boosting
_influences_ the score, it does not impose an ordering.

Sorting _does_ impose an ordering, the question is how to sort and the
answer depends on how fixed (or not) the sorting criteria are. Do they
change with different queries? If not, the very simplest thing to do
is to index a field with a pre-computed sort value. IOW, if your
ordering is _always_ source 5, 9, 7 index a source_sort field that
orders things that way and sort on that. Then I'd have a secondary
sort by score as a tie-breaker.

If that's not the case, perhaps sorting by function (perhaps a custom
function) would work.

Best,
Erick

On Mon, Jul 17, 2017 at 4:30 AM, Florian Waltersdorfer
<Fl...@compass.at> wrote:
> Hi,
>
> I am quite the SolR newbie myself, but have you looked at the resulting scores, e.g. via fl=*,score (that way, you can see/test how your boosting affects the results)?
> In a similar scenario, I am using fixed value boosts for specific field values; "^=[boost]" instead of "^[factor]", for example:
>
> category:9500^=20  source:(5^=20 OR 9^=10 OR 7^=5)
>
> (Actual fixed values open for experimentation.)
>
> Regards,
> Florian
>
> -----Ursprüngliche Nachricht-----
> Von: Luca Dall'Osto [mailto:tenaciousd93@yahoo.it.INVALID]
> Gesendet: Montag, 17. Juli 2017 12:20
> An: solr-user@lucene.apache.org
> Betreff: Get results in multiple orders (multiple boosts)
>
> Hello,
> I'm new in Solr (and in mailing lists..), and I have a question about querying contents in multiple custom orders.
> I 'm trying to query some documents boosted by 2 (or more) fields: I'm able to make a search of 2 day and return results boosted by category field, like this:
>
> ?indent=on
> &defType=edismax
> &q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z])
> &bq=category:9500^2
> &bq=category:1100^1
> &rows=40
> &wt=jsonThis will return all documents of category 9500 first, and 1100 in after.Now I would like to get this documents with a second boost based on another field, called source.I would like to have documents in this order:1) category:9500 AND source:5
> 2) category:9500 AND source:9
> 3) category:9500 AND source:7
> 4) category:1100 AND source:5
> 5) category:1100 AND source:9
> 6) category:1100 AND source:7
> To get this order, I tied with this query:?indent=on &defType=edismax &q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z])
> &bq=category:9500^2+source:(5^3 OR 9^2 OR 7^1)
> &bq=category:1100^1+source:(5^3 OR 9^2 OR 7^1)
> &rows=40
> &wt=json
> How can I apply a double boosts to get the documents in my correct order? Is boost the correct tool for my purpose?Any help will be greatly appreciated. Thanks Luca

AW: Get results in multiple orders (multiple boosts)

Posted by Florian Waltersdorfer <Fl...@compass.at>.
Hi,

I am quite the SolR newbie myself, but have you looked at the resulting scores, e.g. via fl=*,score (that way, you can see/test how your boosting affects the results)?
In a similar scenario, I am using fixed value boosts for specific field values; "^=[boost]" instead of "^[factor]", for example:

category:9500^=20  source:(5^=20 OR 9^=10 OR 7^=5)

(Actual fixed values open for experimentation.)

Regards,
Florian

-----Ursprüngliche Nachricht-----
Von: Luca Dall'Osto [mailto:tenaciousd93@yahoo.it.INVALID] 
Gesendet: Montag, 17. Juli 2017 12:20
An: solr-user@lucene.apache.org
Betreff: Get results in multiple orders (multiple boosts)

Hello,
I'm new in Solr (and in mailing lists..), and I have a question about querying contents in multiple custom orders.
I 'm trying to query some documents boosted by 2 (or more) fields: I'm able to make a search of 2 day and return results boosted by category field, like this:

?indent=on
&defType=edismax
&q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z])
&bq=category:9500^2
&bq=category:1100^1
&rows=40
&wt=jsonThis will return all documents of category 9500 first, and 1100 in after.Now I would like to get this documents with a second boost based on another field, called source.I would like to have documents in this order:1) category:9500 AND source:5
2) category:9500 AND source:9
3) category:9500 AND source:7
4) category:1100 AND source:5
5) category:1100 AND source:9
6) category:1100 AND source:7
To get this order, I tied with this query:?indent=on &defType=edismax &q=(date:[2017-06-16T00:00:00Z TO 2017-06-18T23:59:59Z])
&bq=category:9500^2+source:(5^3 OR 9^2 OR 7^1)
&bq=category:1100^1+source:(5^3 OR 9^2 OR 7^1)
&rows=40
&wt=json
How can I apply a double boosts to get the documents in my correct order? Is boost the correct tool for my purpose?Any help will be greatly appreciated. Thanks Luca

Re: Get results in multiple orders (multiple boosts)

Posted by "alessandro.benedetti" <a....@sease.io>.
"I have different "sort preferences", so I can't build a index and use for
sorting.Maybe I have to sort by category then by source and by language or
by source, then by category and by date"

I would like to focus on this bit.
It is ok to go for a custom function and sort at query time, but I am
curious to explore why an index time solution should not be ok.
You can have these distinct fields :
source_priority
language_priority
category_priority 
ect

This values can be assigned at the documents at indexing time ( using for
example a custom update request processor).
Then at query time you can easily sort on those values in a multi layered
approach :
sort:source_priority desc, category_priority  desc
Of course, if the priority for a source changes quite often or if it's user
dependent, a query time solution would be preferred.





-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
View this message in context: http://lucene.472066.n3.nabble.com/Get-results-in-multiple-orders-multiple-boosts-tp4346304p4346559.html
Sent from the Solr - User mailing list archive at Nabble.com.