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 "hemantverma09@gmail.com" <he...@gmail.com> on 2012/06/20 06:39:16 UTC
Multiple query hit for one query
Hi All
I have a very typical requirement as mentioned below:
Suppose index has two type of data, offers and products. If a user searches
for anything we want to show results in such a way that pages should have
60% of offers and 40% of products and when any one of these two becomes
short then we should increase the % of other one to complete the page size.
For example
total results = 32 containing offers=16 and products=16
Page1 Page2 Page3 Page3
------ ------ ------ ------
offer1 offer7 offer13 product15
offer2 offer8 offer14 product16
offer3 offer9 offer15
offer4 offer10 offer16
offer5 offer11 product9
offer6 offer12 product10
product1 product5 product11
product2 product6 product12
product3 product7 product13
product4 product8 product14
Here ordering of results in a page is not my concern this is something which
I can handle.
I need help to know that where should I write a code to implement such
functionality.
The logic which I am thinking is that web-application should add extra
information in search url which I will use to define percentage ratio of
different type of data. Initially I will fire query with facets and after
getting facet counts I will fire two queries, one will get 6 results of
offers only and second will get 4 results of products only, then I will
merge the results and give back to web-application. I will decide using
facet counts and percentage provided that how many documents I should fetch
for offers and products for different pages. This means I will fire three
queries for every single query and merge the result of last two queries and
return.
Do I write code in solr core? If yes where?
Do I write code outside solr? If yes, should I use Solrj for this?
Please tell me the right approach.
Thanks
Hemant
--
View this message in context: http://lucene.472066.n3.nabble.com/Multiple-query-hit-for-one-query-tp3990466.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Multiple query hit for one query
Posted by Dmitry Kan <dm...@gmail.com>.
Start off with as simple design as possible (probably, the one you have
described) and stay on the client side of solr with solrj api. Start
optimizing, when seeing serious issues, but don't optimize preemptively
(like before you even started coding your app). With solrj you will also be
on a safer side, once you'd need to upgrade solr to some newer version as
solrj api abstracts many internal solr things for you. In some rear case
you would need to change a bit the way you create a server connection or
something similar in a new version of solrj api, but those are usually
peanuts compared to changing / upgrading solr source code.
HTH, Dmitry
On Wed, Jun 20, 2012 at 7:39 AM, hemantverma09@gmail.com <
hemantverma09@gmail.com> wrote:
> Hi All
>
> I have a very typical requirement as mentioned below:
>
> Suppose index has two type of data, offers and products. If a user searches
> for anything we want to show results in such a way that pages should have
> 60% of offers and 40% of products and when any one of these two becomes
> short then we should increase the % of other one to complete the page size.
> For example
>
> total results = 32 containing offers=16 and products=16
> Page1 Page2 Page3 Page3
> ------ ------ ------ ------
> offer1 offer7 offer13 product15
> offer2 offer8 offer14 product16
> offer3 offer9 offer15
> offer4 offer10 offer16
> offer5 offer11 product9
> offer6 offer12 product10
> product1 product5 product11
> product2 product6 product12
> product3 product7 product13
> product4 product8 product14
>
> Here ordering of results in a page is not my concern this is something
> which
> I can handle.
>
> I need help to know that where should I write a code to implement such
> functionality.
> The logic which I am thinking is that web-application should add extra
> information in search url which I will use to define percentage ratio of
> different type of data. Initially I will fire query with facets and after
> getting facet counts I will fire two queries, one will get 6 results of
> offers only and second will get 4 results of products only, then I will
> merge the results and give back to web-application. I will decide using
> facet counts and percentage provided that how many documents I should fetch
> for offers and products for different pages. This means I will fire three
> queries for every single query and merge the result of last two queries and
> return.
>
> Do I write code in solr core? If yes where?
> Do I write code outside solr? If yes, should I use Solrj for this?
> Please tell me the right approach.
>
> Thanks
> Hemant
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Multiple-query-hit-for-one-query-tp3990466.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
--
Regards,
Dmitry Kan