Forum: Ferret ferret/lucene syntax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Bachir (Guest)
on 2007-03-30 00:46
(Received via mailing list)
I jut noticed this example in the lucene documentation*:

   title:(+return +"pink panther")

I have been using this syntax:

   +title:(return AND "pink panther")

Seemingly with success. Are both acceptable? I couldn't find any
documentation on "the plus sign" itself.

Thanks for any pointers.

John

*http://lucene.apache.org/java/docs/queryparsersynt...
20operators
C9dd93aa135988cabf9183d3210665ca?d=identicon&s=25 Jens Kraemer (Guest)
on 2007-03-30 09:41
(Received via mailing list)
On Thu, Mar 29, 2007 at 06:42:16PM -0400, John Bachir wrote:
> I jut noticed this example in the lucene documentation*:
>
>   title:(+return +"pink panther")
>
> I have been using this syntax:
>
>   +title:(return AND "pink panther")
>
> Seemingly with success. Are both acceptable? I couldn't find any
> documentation on "the plus sign" itself.

the plus sign marks a required clause in a query. A document can only be
a hit if it matches that clause. The opposite of this is the minus sign,
documents that match such a clause can't be a hit. Internally, Ferret
doesn't handle AND and such, they get translated by the query parser,
i.e. 'a AND b' --> '+a +b'

Clauses without + or - are optional 'nice to have' clauses, they will
raise a document's score if they match, but the doc won't be excluded
from the hits if they don't. So 'a OR b' gets transformed into 'a b'.

Jens

--
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
kraemer@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
D0347a9af192d23f47056bd253743dcf?d=identicon&s=25 John Joseph Bachir (Guest)
on 2007-03-31 07:28
(Received via mailing list)
On Mar 30, 2007, at 3:32 AM, Jens Kraemer wrote:
> from the hits if they don't. So 'a OR b' gets transformed into 'a b'.
Thanks for that, I actually was completely unaware of the case
without + or -. Very nice.

However, my question was actually more simple: are the semantics of
these two bit of a query the same?


title:(+return +"pink panther")

+title:(return AND "pink panther")


Thanks,
John
4d6a47158a7c8a032e5f6a4da8976d7d?d=identicon&s=25 Erik Hatcher (Guest)
on 2007-03-31 07:40
(Received via mailing list)
On Mar 31, 2007, at 1:18 AM, John Joseph Bachir wrote:

>> Clauses without + or - are optional 'nice to have' clauses, they will
>
> title:(+return +"pink panther")
>
> +title:(return AND "pink panther")

I replied to this the other day, but I think my sending address was
incorrect and it didn't go through - sorry 'bout that.  My reply was
this:
-----
Yup, both are acceptable.  An "AND" actually affects both sides and
forces them to be required, as if you had used + in front.  + is
documented in the document you referenced, just below AND.

If you are combining the queries above with other clauses they may
not be equivalent due to the +title, but if these are the full
queries they are equivalent (at least in Java Lucene).

  Erik
This topic is locked and can not be replied to.