lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arlei Ferreira Farnetani Junior <farnet...@gmail.com>
Subject Re: Example phrase query with lucene version 4
Date Tue, 12 Mar 2013 14:22:46 GMT
In this case you are not using more search PhraseQuery the type that
existed in previous versions ... I would like to use this PhraseQuery by
having the possibility of bidding I use the property and thus enable
setSlop have more content between words.

So it is not recommended to use more Phrasequery?

I thought I had some syntax more this method in version 4 of lucene.

Example:

                PhraseQuery query = new PhraseQuery();
query.setSlop(slop);
for (int i = 0; i < phrase.length; i++) {
query.add(new Term("content", phrase[i]));
}
int hitsPerPage = 10000;
TopScoreDocCollector collector = TopScoreDocCollector.create(
5 * hitsPerPage, false);
indexSearcher.search(query, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;
int hitCount = collector.getTotalHits();
                ....

2013/3/12 Ian Lea <ian.lea@gmail.com>

> QueryParser qp = new QueryParser(Version.whatever, "somefield", new
> WhateverAnalyzer());
> Query q = qp.parse("\"The mouse gnawed the clothes of the king of Rome\"");
>
> and q should be a PhraseQuery if I've got the quoting right.  Some of
> those words might be stop words which might cause you problems
> although probably not if you use the same analyzer and stop word list
> at indexing and search time.
>
> Search using q as you would for any other sort of query.
>
> See also
> http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_.2BAC8_incorrect_hits.3F
> .
>
>
> --
> Ian.
>
>
> On Tue, Mar 12, 2013 at 12:45 AM, Arlei Ferreira Farnetani Junior
> <farnetani@gmail.com> wrote:
> > Hello, could someone give me an example of how to conduct a search in an
> > already built index with Lucene 4 mode phrase query using a specific
> > analyzer. I tested here with the phrase the search query did not work,
> so would
> > appreciate a small example of how to pursue the example of a simple
> sentence in
> > a text, for example: The mouse gnawed the clothes of the king of Rome.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


--

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