Mailing List Archive

AND on two weighted fields
I need to perform an AND query on two fields and weight the results
according to in which fields the results came from. That is, I would need
something like

(field1^2 OR field2^1):(+token1 +token2 +token3)

This means that _all_ of the tokens _have_ to occur in either one of these
fields, and if they are found in field1, the results are weighted higher.

Any ideas on how this can be accomplished?

Clemens



--------------------------------------
http://www.cmarschner.net


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
AW: AND on two weighted fields [ In reply to ]
How about:
+((field1:(+token1 +token2 +token3)^2 field2:(+token1 +token2 +token3))

Christian
> -----Ursprüngliche Nachricht-----
> Von: Clemens Marschner [mailto:cmad@lanlab.de]
> Gesendet: 21 August 2002 11:50
> An: Lucene Developers List
> Betreff: AND on two weighted fields
>
>
> I need to perform an AND query on two fields and weight the results
> according to in which fields the results came from. That is, I would need
> something like
>
> (field1^2 OR field2^1):(+token1 +token2 +token3)
>
> This means that _all_ of the tokens _have_ to occur in either one of these
> fields, and if they are found in field1, the results are weighted higher.
>
> Any ideas on how this can be accomplished?
>
> Clemens
>
>
>
> --------------------------------------
> http://www.cmarschner.net
>
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>



--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
Re: AND on two weighted fields [ In reply to ]
No, since it has to be possible that one or more of the tokens occur in only
one field. That means with the current query parser I can only simulate that
with

(+((field1:(+token1 +token2 +token3)^2 +field2:(token1 token2 token3)))
(+((field1:(token1 +token2 +token3)^2 +field2:(+token1 token2 token3)))
(+((field1:(+token1 token2 +token3)^2 +field2:(token1 +token2 token3)))
...
(+((field1:(token1 token2 token3)^2 +field2:(+token1 +token2 +token3)))

Clemens


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
Re: AND on two weighted fields [ In reply to ]
Clemens Marschner wrote:
> I need to perform an AND query on two fields and weight the results
> according to in which fields the results came from. That is, I would need
> something like
>
> (field1^2 OR field2^1):(+token1 +token2 +token3)
>
> This means that _all_ of the tokens _have_ to occur in either one of these
> fields, and if they are found in field1, the results are weighted higher.
>
> Any ideas on how this can be accomplished?

Index the text in both field1 and field2 in a new field, field3. (Or,
to save space and if your application permits, just add the text from
field1 to field2 too.) Then search for:

field1:(token1^2 token2^2 token3^2) +field3:(+token1 +token2 +token3)

Doug


--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>