"Sponsored" documents for a specific faceted query

21 views
Skip to first unread message

Maxime Beaudoin

unread,
May 7, 2012, 10:18:55 AM5/7/12
to rav...@googlegroups.com
For a very specific faceted query, I need to return one or two documents first.
I fail to see how I could use Lucene's boost to do that and I would like to avoid a query for the "sponsored" documents plus a "where not in" query to exclude those same documents.
Any idea?

Oren Eini (Ayende Rahien)

unread,
May 7, 2012, 10:42:15 AM5/7/12
to rav...@googlegroups.com
I don't understand the question, can you provide more details?

Itamar Syn-Hershko

unread,
May 7, 2012, 10:43:49 AM5/7/12
to rav...@googlegroups.com
If those 2 documents will _always_ be more important than others, giving them a very large Boost value should do it

Otherwise you'd need to either issue 2 queries (could be lazily) and merge the results, or do that through a bundle

On Mon, May 7, 2012 at 5:18 PM, Maxime Beaudoin <beaudoi...@gmail.com> wrote:

Maxime Beaudoin

unread,
May 7, 2012, 10:53:26 AM5/7/12
to rav...@googlegroups.com
Sorry, yes..

Let's say I have 100 documents, Documents have tags. Tags are facets, for example: "region/montreal".

There will be rules where:
  • if Tags = "region/montreal" then put documents "doc/1" and "doc/2" first
A first implementation that I am not totally in favor with:
  • query for documents "doc/1" and "doc/2"
  • query for all other documents matching the query and exclude "doc/1" and "doc/2"
I can see many cons above:
  • 2 queries
  • tweaks are necessary for the pager
  • non native solution
  • extra logic, everywhere
Pro
  • will not fail me.. guaranteed to work 100%
Would you have any other suggestions?

On Monday, May 7, 2012 10:42:15 AM UTC-4, Oren Eini wrote:
I don't understand the question, can you provide more details?

Maxime Beaudoin

unread,
May 7, 2012, 10:55:16 AM5/7/12
to rav...@googlegroups.com
Those 2 documents are only more important than others if the query is very very specific and not always. I've been too vague on my initial post forgive me.


On Monday, May 7, 2012 10:43:49 AM UTC-4, Itamar Syn-Hershko wrote:
If those 2 documents will _always_ be more important than others, giving them a very large Boost value should do it

Otherwise you'd need to either issue 2 queries (could be lazily) and merge the results, or do that through a bundle

Itamar Syn-Hershko

unread,
May 7, 2012, 10:58:34 AM5/7/12
to rav...@googlegroups.com
inline

On Mon, May 7, 2012 at 5:53 PM, Maxime Beaudoin <beaudoi...@gmail.com> wrote:
Sorry, yes..

Let's say I have 100 documents, Documents have tags. Tags are facets, for example: "region/montreal".

There will be rules where:
  • if Tags = "region/montreal" then put documents "doc/1" and "doc/2" first
A first implementation that I am not totally in favor with:
  • query for documents "doc/1" and "doc/2"
  • query for all other documents matching the query and exclude "doc/1" and "doc/2"
In this stage, if you know the IDs for doc/1 and doc/2 you can either:

1. Load them by ID and issue the query, simoltanously and lazily, and update paging counters (+= 2)
2. Or issue a query like YOUR_QUERY AND (someprop:doc/1 OR someprop:doc/2) and boost that last part with a high value

Itamar Syn-Hershko

unread,
May 7, 2012, 10:59:20 AM5/7/12
to rav...@googlegroups.com
Sorry, it should have been YOUR_QUERY OR (...), but note it will always load those docs even if they don't satisfy the query

Maxime Beaudoin

unread,
May 7, 2012, 12:01:14 PM5/7/12
to rav...@googlegroups.com
The document will always satisfy the query. They would be returned anyway but how is the OR going to make them first? I need to guaranteed that they are first when all I have is there IDs.


On Monday, May 7, 2012 10:59:20 AM UTC-4, Itamar Syn-Hershko wrote:
Sorry, it should have been YOUR_QUERY OR (...), but note it will always load those docs even if they don't satisfy the query

On Mon, May 7, 2012 at 5:58 PM, Itamar Syn-Hershko wrote:
inline

Maxime Beaudoin

unread,
May 7, 2012, 12:05:07 PM5/7/12
to rav...@googlegroups.com
Oh sorry, missed the "quoted" answer! Hmm.. (first reaction) let me try that out..!

Maxime Beaudoin

unread,
May 7, 2012, 12:14:07 PM5/7/12
to rav...@googlegroups.com
So far this works: Lang:fr OR (__document_id:"fr/d2da535c-4336-4126-99bd-841bc68a8e13" OR __document_id:"fr/5a68b6fc-0b36-4a55-9e24-9d3fcbbb7e6a")^1000

Thanks a lot!


On Monday, May 7, 2012 10:59:20 AM UTC-4, Itamar Syn-Hershko wrote:
Reply all
Reply to author
Forward
0 new messages