Hi all,

  I am trying to do phrase query search, but hitting into problem of not
getting any results. Basically, i am indexing the document with some fields
in it(String, Text, Numbers and so on). My basic queries are working, but
when i am trying to do PhraseQueries i am not finding any results. I am
using lucene 5.5.0 and below is my psuedo sample code, please let me know if
i am missing something.

// I am using standardAnalyzer;
// index
Document doc = new Document();
String value = "iPod touch has leapt from the distant past—okay";
doc.add(new StringField("summary_s",value , Field.Store.YES));
doc.add(new TextField("summary_t", value, Field.Store.YES));
indexWriter.addDocument(doc);
indexWriter.commit();


// search 
BooleanQuery.Builder booleanQuery = new BooleanQuery.Builder();
PhraseQuery.Builder builder = new PhraseQuery.Builder();
mpq.add(new Term("summary_s", "leapt distant"));
mpq.setSlop(10);
builder.add(new Term("summary_s_en", "leapt distant"));
booleanQuery.add(builder.build(), Occur.MUST)

List<Query> cl = new ArrayList<Query>();
cl.add(booleanQuery.build());
DisjunctionMaxQuery mq = new DisjunctionMaxQuery(cl, 1);
TopDocs topDocs = indexSearcher.search(mq, 10);

Am i missing something ? Also for PhraseQuery, i should be querying against
StringField, is my assumption right ?

Regards.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/PhraseQuery-tp4299871.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to