required keyword in all a document

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

required keyword in all a document

KLessou
Hi,

I would like to find all documents who contain "France, Flag, French".

I've got docs like this one :
<doc>
    <str name="id">...</str>
    <str name="k1_en">wordA,wordB,france, ...</str>
    <str name="k2_en">wordA,wordB,flag, ...</str>
    <str name="k3_en">wordA,wordB,french, ...</str>
    ...
</doc>

I can't make my query like this :
k1_en:(+france +flag +french)^100 OR k2_en:(+france +flag +french)^10 OR
k3_en:(+france +flag +french)

So, this only way to do what I want is to generate this query :

(k1_en:france^100 OR k2_en:france^10 OR k3_en:france)
AND
(k1_en:flag^100 OR k2_en:flag^10 OR k3_en:flag)
AND
(k1_en:french^100 OR k2_en:french^10 OR k3_en:french)

Is there a better/more simple way to do this ?

Thx in advance !

--
~~~~~
| klessou |
~~~~~
Reply | Threaded
Open this post in threaded view
|

Re: required keyword in all a document

KLessou
MultiFieldQueryParser seems to generate what I want :
http://hudson.zones.apache.org/hudson/job/Lucene-trunk/javadoc//org/apache/lucene/queryParser/MultiFieldQueryParser.html

But is there a Php version ?

On Mon, Oct 6, 2008 at 1:24 PM, KLessou <[hidden email]> wrote:

> Hi,
>
> I would like to find all documents who contain "France, Flag, French".
>
> I've got docs like this one :
> <doc>
>     <str name="id">...</str>
>     <str name="k1_en">wordA,wordB,france, ...</str>
>     <str name="k2_en">wordA,wordB,flag, ...</str>
>     <str name="k3_en">wordA,wordB,french, ...</str>
>     ...
> </doc>
>
> I can't make my query like this :
> k1_en:(+france +flag +french)^100 OR k2_en:(+france +flag +french)^10 OR
> k3_en:(+france +flag +french)
>
> So, this only way to do what I want is to generate this query :
>
> (k1_en:france^100 OR k2_en:france^10 OR k3_en:france)
> AND
> (k1_en:flag^100 OR k2_en:flag^10 OR k3_en:flag)
> AND
> (k1_en:french^100 OR k2_en:french^10 OR k3_en:french)
>
> Is there a better/more simple way to do this ?
>
> Thx in advance !
>
> --
> ~~~~~
> | klessou |
> ~~~~~
>



--
~~~~~
| klessou |
~~~~~
Reply | Threaded
Open this post in threaded view
|

Re: required keyword in all a document

KLessou
In reply to this post by KLessou
On Mon, Oct 6, 2008 at 1:24 PM, KLessou <[hidden email]> wrote:

> Hi,
>
> I would like to find all documents who contain "France, Flag, French".
>
> I've got docs like this one :
> <doc>
>     <str name="id">...</str>
>     <str name="k1_en">wordA,wordB,france, ...</str>
>     <str name="k2_en">wordA,wordB,flag, ...</str>
>     <str name="k3_en">wordA,wordB,french, ...</str>
>     ...
> </doc>
>
> I can't make my query like this :
> k1_en:(+france +flag +french)^100 OR k2_en:(+france +flag +french)^10 OR
> k3_en:(+france +flag +french)
>

because I only get this type of document :
<doc>
    <str name="id">...</str>
    <str name="k1_en">wordA,wordB,france,flag,french, ...</str> <!-- all
good keywords are here -->
    <str name="k2_en">wordA,wordB, ...</str>
    <str name="k3_en">wordA,wordB, ...</str>
    ...
</doc>


>
> So, this only way to do what I want is to generate this query :
>
> (k1_en:france^100 OR k2_en:france^10 OR k3_en:france)
> AND
> (k1_en:flag^100 OR k2_en:flag^10 OR k3_en:flag)
> AND
> (k1_en:french^100 OR k2_en:french^10 OR k3_en:french)
>
> Is there a better/more simple way to do this ?
>
> Thx in advance !
>
> --
> ~~~~~
> | klessou |
> ~~~~~
>



--
~~~~~
| klessou |
~~~~~
Reply | Threaded
Open this post in threaded view
|

Re: required keyword in all a document

Jason Rennie-2
In reply to this post by KLessou
Sounds like the DisMax handler would work well for you.  I'm no expert, but
I'm fairly certain that if you created a solr.DisMaxRequestHandler handler
with "qf" containing those three fields, you could issue the query "+france
+flag +french" and get the desired results.

Jason

On Mon, Oct 6, 2008 at 7:24 AM, KLessou <[hidden email]> wrote:

> Hi,
>
> I would like to find all documents who contain "France, Flag, French".
>
> I've got docs like this one :
> <doc>
>    <str name="id">...</str>
>    <str name="k1_en">wordA,wordB,france, ...</str>
>    <str name="k2_en">wordA,wordB,flag, ...</str>
>    <str name="k3_en">wordA,wordB,french, ...</str>
>    ...
> </doc>
>
> I can't make my query like this :
> k1_en:(+france +flag +french)^100 OR k2_en:(+france +flag +french)^10 OR
> k3_en:(+france +flag +french)
>
> So, this only way to do what I want is to generate this query :
>
> (k1_en:france^100 OR k2_en:france^10 OR k3_en:france)
> AND
> (k1_en:flag^100 OR k2_en:flag^10 OR k3_en:flag)
> AND
> (k1_en:french^100 OR k2_en:french^10 OR k3_en:french)
>
> Is there a better/more simple way to do this ?
>
> Thx in advance !
>
> --
> ~~~~~
> | klessou |
> ~~~~~
>



--
Jason Rennie
Head of Machine Learning Technologies, StyleFeeder
http://www.stylefeeder.com/
Samantha's blog & pictures: http://samanthalyrarennie.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: required keyword in all a document

hossman

: Sounds like the DisMax handler would work well for you.  I'm no expert, but
: I'm fairly certain that if you created a solr.DisMaxRequestHandler handler
: with "qf" containing those three fields, you could issue the query "+france
: +flag +french" and get the desired results.

correct.


-Hoss