and != AND?  
http://lucene.apache.org/core/4_4_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#AND

It works for or rather than OR because that is the default.  If you
had a doc with id="or" you'd find that too, I think.

It looks odd to be escaping the value when you are storing it.  That
may not be necessary, but if it's what you want, fine.


--
Ian.


On Fri, Aug 16, 2013 at 3:55 PM, Maksym Krasovskiy <m...@ciklum.com> wrote:
> Hi!
> I have documents with two fields id and name. I create index with code:
> Document doc = new Document();
> doc.add(new TextField("id", id), Store.YES));
> doc.add(new TextField("name", QueryParser.escape(name), Store.YES));
> indexWriter.addDocument(doc);
>
> When I try to search with query with code:
> QueryParser qp = new QueryParser(LUCENE_VERSION, "name", new 
> WhitespaceAnalyzer(LUCENE_VERSION));
> getIndexSearcher().search(qp.parse(“id:( 134586 or  134583 )”), 10);
> I got only 2 results as expected
>
> But when I try to search with query:
> (name:test) and id:( 134586 or  134583 )
> I got many results, but I expect only documents with id  =  134586 or  134583 
>  which have test in name field. Why lucene add to search results additional 
> documents which not match search criteria?
>
>
> --
> Krasovskiy Maxim

---------------------------------------------------------------------
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