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 Elaine Li <el...@gmail.com> on 2009/10/02 21:46:58 UTC

search by some functionality

Hi,

My doc has three fields, say field1, field2, field3.

My search would be q=field1:string1 && field2:string2. I also need to
do some computation and comparison of the string1 and string2 with the
contents in field3 and then determine if it is a hit.

What can I do to implement this?

Thanks.

Elaine

Re: search by some functionality

Posted by Elaine Li <el...@gmail.com>.
Hi Chantal,

I thought about that - taking care of the comparison at the index
time. But the user's input scenarios are countless. That method will
not cover all the cases.
Doing comparison on the fly is better. I am just confused which way to
go since I have not done much customization of solr by now.

I see customized function query and customized request handler are two
options. I wish I can get more details about how to do that. I
appreciate if i can get some examples.

Thanks.

Elaine


On Mon, Oct 5, 2009 at 10:35 AM, Chantal Ackermann
<ch...@btelligent.de> wrote:
> Hi Elaine,
>
> couldn't you do that comparison at index time and store the result in an
> additional field? At query time you could include that other field as
> condition.
>
> Cheers,
> Chantal
>
> Elaine Li schrieb:
>>
>> Hi Shalin,
>>
>> Thanks for your attention.
>>
>> I am implementing a language translation search. The field1 and field2
>> are two language's sentence pair. field3 is a table of indexes of
>> words in field1 and field2. The table was created by some independent
>> algorithm. If string1 and string2 can be found aligned in the table,
>> then it is a hit. Otherwise, it should not return.
>>
>> Hope I clarified what i need to achieve. Your help is greatly appreciated!
>>
>> Thanks!
>>
>> Elaine
>>
>> On Mon, Oct 5, 2009 at 5:57 AM, Shalin Shekhar Mangar
>> <sh...@gmail.com> wrote:
>>>
>>> On Sat, Oct 3, 2009 at 1:16 AM, Elaine Li <el...@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> My doc has three fields, say field1, field2, field3.
>>>>
>>>> My search would be q=field1:string1 && field2:string2. I also need to
>>>> do some computation and comparison of the string1 and string2 with the
>>>> contents in field3 and then determine if it is a hit.
>>>>
>>>> What can I do to implement this?
>>>>
>>> What exactly are you trying to achieve? What is the
>>> computation/comparison
>>> that you need to do?
>>>
>>> --
>>> Regards,
>>> Shalin Shekhar Mangar.
>>>
>

Re: search by some functionality

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

couldn't you do that comparison at index time and store the result in an 
additional field? At query time you could include that other field as 
condition.

Cheers,
Chantal

Elaine Li schrieb:
> Hi Shalin,
> 
> Thanks for your attention.
> 
> I am implementing a language translation search. The field1 and field2
> are two language's sentence pair. field3 is a table of indexes of
> words in field1 and field2. The table was created by some independent
> algorithm. If string1 and string2 can be found aligned in the table,
> then it is a hit. Otherwise, it should not return.
> 
> Hope I clarified what i need to achieve. Your help is greatly appreciated!
> 
> Thanks!
> 
> Elaine
> 
> On Mon, Oct 5, 2009 at 5:57 AM, Shalin Shekhar Mangar
> <sh...@gmail.com> wrote:
>> On Sat, Oct 3, 2009 at 1:16 AM, Elaine Li <el...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> My doc has three fields, say field1, field2, field3.
>>>
>>> My search would be q=field1:string1 && field2:string2. I also need to
>>> do some computation and comparison of the string1 and string2 with the
>>> contents in field3 and then determine if it is a hit.
>>>
>>> What can I do to implement this?
>>>
>> What exactly are you trying to achieve? What is the computation/comparison
>> that you need to do?
>>
>> --
>> Regards,
>> Shalin Shekhar Mangar.
>>

Re: search by some functionality

Posted by Elaine Li <el...@gmail.com>.
Hi Shalin,

Thanks for your attention.

I am implementing a language translation search. The field1 and field2
are two language's sentence pair. field3 is a table of indexes of
words in field1 and field2. The table was created by some independent
algorithm. If string1 and string2 can be found aligned in the table,
then it is a hit. Otherwise, it should not return.

Hope I clarified what i need to achieve. Your help is greatly appreciated!

Thanks!

Elaine

On Mon, Oct 5, 2009 at 5:57 AM, Shalin Shekhar Mangar
<sh...@gmail.com> wrote:
> On Sat, Oct 3, 2009 at 1:16 AM, Elaine Li <el...@gmail.com> wrote:
>
>> Hi,
>>
>> My doc has three fields, say field1, field2, field3.
>>
>> My search would be q=field1:string1 && field2:string2. I also need to
>> do some computation and comparison of the string1 and string2 with the
>> contents in field3 and then determine if it is a hit.
>>
>> What can I do to implement this?
>>
>
> What exactly are you trying to achieve? What is the computation/comparison
> that you need to do?
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: search by some functionality

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Sat, Oct 3, 2009 at 1:16 AM, Elaine Li <el...@gmail.com> wrote:

> Hi,
>
> My doc has three fields, say field1, field2, field3.
>
> My search would be q=field1:string1 && field2:string2. I also need to
> do some computation and comparison of the string1 and string2 with the
> contents in field3 and then determine if it is a hit.
>
> What can I do to implement this?
>

What exactly are you trying to achieve? What is the computation/comparison
that you need to do?

-- 
Regards,
Shalin Shekhar Mangar.

Re: search by some functionality

Posted by Sandeep Tagore <sa...@gmail.com>.
Hi Elaine,
You can implement a function query in Solr in two ways:
 1. Using  Dismax request handler (with bf parameter).
 2. Using the standard request handler (with _val_ field).
I recommend the first option. 

Sandeep


Elaine Li wrote:
> 
> Hi Sandeep,
> 
> I read about this chapter before. It did not mention how to create my
> own customized function.
> Can you point me to some instructions?
> Thanks.
> Elaine
> 
> 

-- 
View this message in context: http://www.nabble.com/search-by-some-functionality-tp25721533p25767741.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: search by some functionality

Posted by Chris Hostetter <ho...@fucit.org>.
Actually, I forgot that the new frange query parser can let you filter on 
the output of a function...

http://www.lucidimagination.com/blog/tag/frange/

: : Maybe I'm missing something, but function queries aren't involved in
: : determining whether a document matches or not, only its score.  How is a a
: : custom function / value-source going to filter?
: 
: it's not ... i didn't realize that was the context of the question, i was 
: just answering the specific question about how to create custom functions.



-Hoss


Re: search by some functionality

Posted by Chris Hostetter <ho...@fucit.org>.
: Maybe I'm missing something, but function queries aren't involved in
: determining whether a document matches or not, only its score.  How is a a
: custom function / value-source going to filter?

it's not ... i didn't realize that was the context of the question, i was 
just answering the specific question about how to create custom functions.



-Hoss


Re: search by some functionality

Posted by "David Smiley @MITRE.org" <DS...@mitre.org>.
Maybe I'm missing something, but function queries aren't involved in
determining whether a document matches or not, only its score.  How is a a
custom function / value-source going to filter?

~ David Smiley


hossman wrote:
> 
> 
> : I read about this chapter before. It did not mention how to create my
> : own customized function.
> : Can you point me to some instructions?
> 
> The first step is to figure out how you can code your custom functionality 
> as an extension of the ValueSource class...
> 
> http://lucene.apache.org/solr/api/org/apache/solr/search/function/ValueSource.html
> 
> ...which has to be able to generate DocValues implementation for an 
> IndexReader.  DocValues is where you would some numeric score for each 
> document based on whatever criteria you wanted (including arguments passed 
> in when your ValueSource is constructed, like field names and constants)
> 
> Then you need a simple ValueSourceParser class to be able to specify when 
> to use your ValueSource, and that's what you register in solrconfig.xml...
> 
> http://wiki.apache.org/solr/SolrPlugins#ValueSourceParser
> 
> 
> 
> -Hoss
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/search-by-some-functionality-tp25721533p25779702.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: search by some functionality

Posted by Chris Hostetter <ho...@fucit.org>.
: I read about this chapter before. It did not mention how to create my
: own customized function.
: Can you point me to some instructions?

The first step is to figure out how you can code your custom functionality 
as an extension of the ValueSource class...

http://lucene.apache.org/solr/api/org/apache/solr/search/function/ValueSource.html

...which has to be able to generate DocValues implementation for an 
IndexReader.  DocValues is where you would some numeric score for each 
document based on whatever criteria you wanted (including arguments passed 
in when your ValueSource is constructed, like field names and constants)

Then you need a simple ValueSourceParser class to be able to specify when 
to use your ValueSource, and that's what you register in solrconfig.xml...

http://wiki.apache.org/solr/SolrPlugins#ValueSourceParser



-Hoss


Re: search by some functionality

Posted by Elaine Li <el...@gmail.com>.
Hi Sandeep,

I read about this chapter before. It did not mention how to create my
own customized function.
Can you point me to some instructions?

Thanks.

Elaine

On Mon, Oct 5, 2009 at 10:15 AM, Sandeep Tagore
<sa...@gmail.com> wrote:
>
> Hi Elaine,
> You can make use of  http://wiki.apache.org/solr/FunctionQuery Function
> Query  to achieve this. You can do the computations in your customized
> function to determine whether it is a hit or not.
>
> Sandeep
>
> -----
> Sandeep Tagore
>
> --
> View this message in context: http://www.nabble.com/search-by-some-functionality-tp25721533p25751627.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Re: search by some functionality

Posted by Sandeep Tagore <sa...@gmail.com>.
Hi Elaine,
You can make use of  http://wiki.apache.org/solr/FunctionQuery Function
Query  to achieve this. You can do the computations in your customized
function to determine whether it is a hit or not.

Sandeep

-----
Sandeep Tagore

-- 
View this message in context: http://www.nabble.com/search-by-some-functionality-tp25721533p25751627.html
Sent from the Solr - User mailing list archive at Nabble.com.