Hi everyone, I am building an autocomplete index. The index contains both the names and a small set of fixed types. The intention is that type matches will always come first, followed by name matches.
I am using a PrefixQuery to do substring matching. Confusingly, I am finding that very short prefix matches sometimes will return no results when combined with an additional filter. For example, I have a document "body:german type:TYPE". The query "+(type:TYPE) +body:ge*" matches this document. The query "+(type:TYPE) +body:g*" does not. Double confusingly, it works fine in Luke -- just not when I build the query by hand. Here is how I create the document: Document doc = new Document(); doc.add(new Field("body", "German", TextField.TYPE_STORED)); doc.add(new Field("type", "TYPE", StringField.TYPE_STORED)); Here is how I build the query: Query allowedTypes = new BooleanQuery(); allowedTypes.add(new TermQuery(new Term("type", "TYPE")), Occur.SHOULD); Query prefixQuery = new PrefixQuery(new Term("body", "ge")); prefixQuery.setRewriteMethod(new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(10000)); Query mainQuery = new BooleanQuery(); mainQuery.add(allowedTypes, Occur.MUST); mainQuery.add(prefixQuery, Occur.MUST); Am I missing something obvious? Thanks, Steven Schlansker --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org