lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tri Cao <tm...@me.com>
Subject Re: Lucene Query
Date Tue, 19 Aug 2014 20:45:24 GMT
Oh sorry guys, ignore what I said. I am going to get myself a coffee. Uwe is absolutely correct
here.

On Aug 19, 2014, at 01:13 PM, Uwe Schindler <uwe@thetaphi.de> wrote:

Hi,
Look at his docs. He has only 2 docs, the second one 3 keywords.

I would use a simple phrase query with a slop value < Analyzers positionIncrementGap. This
is the gap between fields with same name. Span or phrase cannot cross the gap, if slop if
small enough, but large enough to find the terms next to each other.

SpanQuery is not needed. Phrase does all thats needed. Slop is like edit distance of whole
terms, order does not matter.

Uwe

Am 19. August 2014 22:05:23 MESZ, schrieb Tri Cao <tmcao@me.com    >:
        >OR operator does that, AND only returns docs with ALL terms present.
        >
        >Note that you have two options here
        >1. Create a BooleanQuery object (see the Java doc I linked below) and
        >programatically
        >add the term queries with the following constraint:
        >http://lucene.apache.org/core/4_6_0/core/org/apache/lucene/search/BooleanClause.Occur.html#MUST_NOT
        >
        >2. Use Lucene classic QueryParser and pass in the query string "states
        >AND america AND united"
        >
        >I would suggest 1) if you are going to learn more about Lucene, and 2)
        >if you are just want to get some thing out.
        >
        >Hope this helps,
        >Tri
        >
        >On Aug 19, 2014, at 12:17 PM, Jin Guang Zheng <zhengj3@rpi.edu      >
wrote:
        >
        >Thanks for reply, but won't BooleanQuery return both doc1 and doc2 with
        >query:
        >
        >label:States AND label:America AND label:United
        >
        >Best,
        >Jin
        >
        >
        >On Tue, Aug 19, 2014 at 2:07 PM, Tri Cao <tmcao@me.com        >
wrote:
        >
        >         > given that example, the easy way is a boolean AND query
of all
        >the terms:
        >                >
        >                >
        >         >
        >http://lucene.apache.org/core/4_6_0/core/org/apache/lucene/search/BooleanQuery.html
        >                >
        >         > However, if your corpus is more sophisticated you'll find
that
        >relevance
        >                > ranking is not always that trivial :)
        >                >
        >         > On Aug 19, 2014, at 11:00 AM, Jin Guang Zheng <zhengj3@rpi.edu
        >     > wrote:
        >                >
        >                > Hi,
        >                >
        >                > I am wondering if someone can help me on this:
        >                >
        >                > I have index:
        >                >
        >                > doc 1 -- label: United States of America
        >                >
        >                > doc 2 -- label: United
        >                > doc 2 -- label: America
        >                > doc 2 -- label: States
        >                >
        >         > I am wondering how to generate a query with terms: states
        >united america
        >                >
        >                > so only doc 1 returns.
        >                >
        >                >
        >                > I was thinking SpanNearQuery, but can't make
it work.
        >                >
        >                > Thanks,
        >                > Jin
        >                >
        >                >

--
Uwe Schindler
H.-H.-Meier-Allee 63, 28213 Bremen
http://www.thetaphi.de

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
    • Unnamed multipart/related (inline, None, 0 bytes)
View raw message