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 "Noam G." <no...@gmail.com> on 2010/01/21 16:14:38 UTC

Choosing what document to return.

Hi Guys,
 
I'll start by thanking every one for an amazing search engine!
 
What am I trying to do? Basically what I need is the ability to do some kind
of "switch" or an "if-else" flow based on the field value and a parameter
that I will pass using the query string. The result will be documents that
comply with this logic.
 
For example (myval1, myval2 and myval3 are the params from the query
string):
if(index_value == myval1) {
    if(other_index_value == 1){
        don't return the document;
    } else {
        return the document;
    } 
}else if(index_value == myval2) {
.......
}else if(index_value == myval3) {
....... 
} 

What should I override to implement this?

Thank you very much,

Noam.
-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259310.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by "Smiley, David W." <ds...@mitre.org>.
I don't understand your question.  Are myval1...3 fixed and controlled by your interface or are they an arbitrary N number of query words from a user query?  In any case, you may need to write a request handler.

~ David Smiley
Author: http://www.packtpub.com/solr-1-4-enterprise-search-server/

On Jan 21, 2010, at 10:14 AM, Noam G. wrote:

> 
> Hi Guys,
> 
> I'll start by thanking every one for an amazing search engine!
> 
> What am I trying to do? Basically what I need is the ability to do some kind
> of "switch" or an "if-else" flow based on the field value and a parameter
> that I will pass using the query string. The result will be documents that
> comply with this logic.
> 
> For example (myval1, myval2 and myval3 are the params from the query
> string):
> if(index_value == myval1) {
>    if(other_index_value == 1){
>        don't return the document;
>    } else {
>        return the document;
>    } 
> }else if(index_value == myval2) {
> .......
> }else if(index_value == myval3) {
> ....... 
> } 
> 
> What should I override to implement this?
> 
> Thank you very much,
> 
> Noam.
> -- 
> View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259310.html
> Sent from the Solr - User mailing list archive at Nabble.com.
> 




Re: Choosing what document to return.

Posted by "Noam G." <no...@gmail.com>.
Hi Mei

Thank you very much - looks good :-)

Noam.
-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27293083.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by "Noam G." <no...@gmail.com>.
Hi Mei,

You are right.

Suddenlly it looks clear - is it too late? :-)

Let me look at it again tomorrow.

Thank you very much :-)

Noam.


Wangsheng Mei wrote:
> 
> 2010/1/22 Noam G. <no...@gmail.com>
> 
>>
>> Hi Mei,
>>
>> I replyed to you directlly by mistake - so here is the message again -
>> allmost the same ;-)
>>
>> I think I'm getting it now :-)
>>
>> Let's take your suggestion:
>> name:abc AND ((network_id:network1 AND payout:[minval TO *]) OR
>> -network_id:network1)
>>
>> What I need is not the value of payout but, 50% of payout - and in
>> another
>> query a differnt value - I guess I need to use a function?
>>
> 
> if you need 50% of payout to be bigger than minval,  it's equal to "payout
> bigger than 2*minval", right?
> why not calculate 2*minval first as newMinval = 2*minval, and use
> name:abc AND ((network_id:network1 AND payout:[newMinval TO *]) OR
> -network_id:network1)?
> :-)
> 
>>
>> How can I do it?
>>
>> And one more time - thank you :-)
>>
>> Noam.
>> --
>> View this message in context:
>> http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27261312.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> 梅旺生
> 
> 

-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27263025.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by Wangsheng Mei <ha...@gmail.com>.
2010/1/22 Noam G. <no...@gmail.com>

>
> Hi Mei,
>
> I replyed to you directlly by mistake - so here is the message again -
> allmost the same ;-)
>
> I think I'm getting it now :-)
>
> Let's take your suggestion:
> name:abc AND ((network_id:network1 AND payout:[minval TO *]) OR
> -network_id:network1)
>
> What I need is not the value of payout but, 50% of payout - and in another
> query a differnt value - I guess I need to use a function?
>

if you need 50% of payout to be bigger than minval,  it's equal to "payout
bigger than 2*minval", right?
why not calculate 2*minval first as newMinval = 2*minval, and use
name:abc AND ((network_id:network1 AND payout:[newMinval TO *]) OR
-network_id:network1)?
:-)

>
> How can I do it?
>
> And one more time - thank you :-)
>
> Noam.
> --
> View this message in context:
> http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27261312.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>


-- 
梅旺生

Re: Choosing what document to return.

Posted by "Noam G." <no...@gmail.com>.
Hi Mei,

I replyed to you directlly by mistake - so here is the message again -
allmost the same ;-)

I think I'm getting it now :-)

Let's take your suggestion:
name:abc AND ((network_id:network1 AND payout:[minval TO *]) OR
-network_id:network1)

What I need is not the value of payout but, 50% of payout - and in another
query a differnt value - I guess I need to use a function?

How can I do it?

And one more time - thank you :-)

Noam.
-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27261312.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by Wangsheng Mei <ha...@gmail.com>.
hi, Noam, you can try this one,
name:abc AND ((network_id:network1 AND payout:[minval TO *]) OR
-network_id:network1)

2010/1/21 Noam G. <no...@gmail.com>

>
> Hi All (Erick, David...)
>
> Thanks for replying.
>
> Let me try to elaborate:
> - Each document holds a string value called name, an int parameter called
> payout a parameter called network_id.
> - Name can be any string.
> - Payout can be any number.
> - Network_id can be one of maximum 20 available values (for example
> "network1" , "network2" and so on).
>
> The query will need to pass:
> - name:"abc" (for example)
> - network:"network1"
> - minval:20
>
> The result will return only:
> - Documents that have "abc" in their name (just to empesize the need of the
> regular query also)
> - If document.network_id == "network1" then
>   if payout>minval then
>      add the document to the results.
>  end if
>  else
>     don't add the document to the results.
>  end if
>
> As you can see the problem I have is with the "if-else".
>
> I hope it was clearer now :-)
>
> Noam.
> --
> View this message in context:
> http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259888.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>


-- 
梅旺生

Re: Choosing what document to return.

Posted by "Noam G." <no...@gmail.com>.
Hi All (Erick, David...)

Thanks for replying.
 
Let me try to elaborate:
- Each document holds a string value called name, an int parameter called
payout a parameter called network_id.
- Name can be any string.
- Payout can be any number.
- Network_id can be one of maximum 20 available values (for example
"network1" , "network2" and so on).
 
The query will need to pass:
- name:"abc" (for example)
- network:"network1"
- minval:20
 
The result will return only:
- Documents that have "abc" in their name (just to empesize the need of the
regular query also)
- If document.network_id == "network1" then
   if payout>minval then
      add the document to the results.
  end if
 else
     don't add the document to the results.
 end if
 
As you can see the problem I have is with the "if-else".
 
I hope it was clearer now :-)
 
Noam.
-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259888.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by Erick Erickson <er...@gmail.com>.
What's the higher-level task you're trying to accomplish?
Because on a quick read it looks like you're trying
something that's akin to a join between two indexes,
and if that's accurate I have great fears about
performance. I guess it boils down to how costly
getting your other_index_value is....

Mostly, I'm trying to be sure this isn't an XY problem
before you waste time implementing a solution that
won't work out....


Erick

On Thu, Jan 21, 2010 at 10:14 AM, Noam G. <no...@gmail.com> wrote:

>
> Hi Guys,
>
> I'll start by thanking every one for an amazing search engine!
>
> What am I trying to do? Basically what I need is the ability to do some
> kind
> of "switch" or an "if-else" flow based on the field value and a parameter
> that I will pass using the query string. The result will be documents that
> comply with this logic.
>
> For example (myval1, myval2 and myval3 are the params from the query
> string):
> if(index_value == myval1) {
>    if(other_index_value == 1){
>        don't return the document;
>    } else {
>        return the document;
>    }
> }else if(index_value == myval2) {
> .......
> }else if(index_value == myval3) {
> .......
> }
>
> What should I override to implement this?
>
> Thank you very much,
>
> Noam.
> --
> View this message in context:
> http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259310.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Re: Choosing what document to return.

Posted by "Noam G." <no...@gmail.com>.
Hi Mei,

The problem is that I need to do a calculation on the field.
So I assumed I need to extend one of the classes in order to be able to do a
calculation on a field with an if-else capabailities.

Don't I?

Noam.
-- 
View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259945.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Choosing what document to return.

Posted by Wangsheng Mei <ha...@gmail.com>.
I am not very sure if you are talking about a bit complex boolean queries.
According stardard boolean logic, complex if-else would be normalized by
using union, intersection, not.

you omited some of your logic, lets assume it as:
if( FieldA == myval1) {
   if(FieldB == 1){
       don't return the document;
   } else {
       return the document;
   }
}else if(FieldA  == myval2) {
 if(FieldC == 1){
       don't return the document;
   } else {
       return the document;
   }
}else if(FieldA == myval3) {
  if(FieldD == 1){
       don't return the document;
   } else {
       return the document;
   }
}

then you would use a boolean query as:
(FieldA:myval1 -FieldB:1) OR (FieldA:myval2 -FieldC:1) OR (FieldA:myval3
-FieldD:1)

see, this is a normalized boolean logic.
hope it helps.

2010/1/21 Noam G. <no...@gmail.com>

>
> Hi Guys,
>
> I'll start by thanking every one for an amazing search engine!
>
> What am I trying to do? Basically what I need is the ability to do some
> kind
> of "switch" or an "if-else" flow based on the field value and a parameter
> that I will pass using the query string. The result will be documents that
> comply with this logic.
>
> For example (myval1, myval2 and myval3 are the params from the query
> string):
> if(index_value == myval1) {
>    if(other_index_value == 1){
>        don't return the document;
>    } else {
>        return the document;
>    }
> }else if(index_value == myval2) {
> .......
> }else if(index_value == myval3) {
> .......
> }
>
> What should I override to implement this?
>
> Thank you very much,
>
> Noam.
> --
> View this message in context:
> http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259310.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>


-- 
梅旺生

Re: Choosing what document to return.

Posted by Chantal Ackermann <ch...@btelligent.de>.
Hi Noam,

if you know about those rules at index time, you should put the 
information into the index and simply query only for those documents 
that have the desired value(s).

Cheers,
Chantal

Noam G. schrieb:
> Hi Guys,
> 
> I'll start by thanking every one for an amazing search engine!
> 
> What am I trying to do? Basically what I need is the ability to do some kind
> of "switch" or an "if-else" flow based on the field value and a parameter
> that I will pass using the query string. The result will be documents that
> comply with this logic.
> 
> For example (myval1, myval2 and myval3 are the params from the query
> string):
> if(index_value == myval1) {
>     if(other_index_value == 1){
>         don't return the document;
>     } else {
>         return the document;
>     }
> }else if(index_value == myval2) {
> .......
> }else if(index_value == myval3) {
> .......
> }
> 
> What should I override to implement this?
> 
> Thank you very much,
> 
> Noam.
> --
> View this message in context: http://old.nabble.com/Choosing-what-document-to-return.-tp27259310p27259310.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>