<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">There are several steps to the query DSL:<div> 1. implement the initial ideas and see what problems we face and how well that fits</div><div> 2. add analyzers into the mix to transparently use the right one</div><div> 3. add parameters that use the conversion bridge (not sure how well that could fly but an interesting idea</div><div> 4. build up the stack of operators integrated into the DSL</div><div> 5. string based QL using this API (not convinced yet but why not).</div><div><br></div><div><br></div><div>Navin will start working on 1 and if things go well 2 (we will have a fantastic tool already we do just that).</div><div><br></div><div>Here are my notes based on the initial idea + the feedback received.</div><div><br></div><div><br></div><div><span class="Apple-style-span" style="font-family: Arial; "><div><b><div><span class="Apple-style-span" style="font-weight: normal;">A few remarks:</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - it asks the analyzer so that we correctly apply the analyzer on terms</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - it has a few query factory methods</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - it contains a few orthogonal operations</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - I am not quite satisfied with how boolean is handled, any idea?</span></div><div><span class="Apple-style-span" style="font-weight: normal;"><br></span></div><div><span class="Apple-style-span" style="font-weight: normal;">Design remarks:</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - should we use interfaces or plain implementations? I would start with plain implementations to make things easier</span></div><div><span class="Apple-style-span" style="font-weight: normal;"> - let's put it in org.hibernate.search.query.dsl for now</span></div><div><span class="Apple-style-span" style="font-weight: normal;"><br></span></div><div>Examples</div><div><br></div><div><span class="Apple-style-span" style="font-weight: normal;"><div>SealedQueryBuilder qb = searchFactory.withEntityAnalyzer(Address.class);</div><div><br></div><div>Query luceneQuery = qb.must()</div><div> .add(</div><div> qb.should()</div><div> .add( qb.term("city", "Atlanta").boostedTo(4).createQuery() )</div><div> .add( qb.term("address1", "Peachtree").fuzzy().createQuery() )</div><div> )</div><div> .add(</div><div> qb.range("movingDate").from("200604").to("201201").exclusive().createQuery()</div><div> )</div><div> .createQuery();</div><div> </div></span></div></b></div><div><b><br></b></div><div><b>Analyzer choice</b></div><div>queryBuilder.withAnalyzer(Analyzer)</div><div>queryBuilder.withEntityAnalyzer(Class<?>)</div><div>queryBuilder.basedOnEntityAnalyzer(Class<?>)</div><div> .overridesForField(String field, Analyzer)</div><div> .overridesForField(String field, Analyzer)</div><div> .build() //sucky name</div><div>returns a SealedQueryBuilder //sucky name</div><div><br></div><div>SealedQueryBuilder contains the factory methods</div><div><br></div><div><b><br></b></div><div><b>Factory methods</b></div><div>Hosted onSealedQueryBuilder</div><div><br></div><div>//Alternative</div><div>.term().on(String field).matches(String text)</div><div>.on(String field).matches(String text)</div><div><br></div><div><br></div><div>.term(String field, String text) //define a new query</div><div>.term(String field, String text) //define a new query</div><div> .ignoreAnalyzer() //ignore the analyzer, optional</div><div> .fuzzy() //API prevent wildcard calls, optional</div><div> .threshold() //optional</div><div> .prefixLengh() //optional</div><div>.term(String field, String value)</div><div> .wildcard() //API prevent fuzzy calls, optional</div><div><br></div><div>//range query</div><div>.rangeQuery(String field)</div><div> .from(String text)</div><div> .to(String text)</div><div> .exclusive() //optional</div><div> .constantScore() //optional, due to constantScoreRangeQuery but in practice inherited from the common operations</div><div><br></div><div>//match all docs</div><div>.all() </div><div><br></div><div>//phrase query</div><div>.phrase(String field)</div><div> .ignoreAnalyzer() //ignore the analyzer, optional</div><div> .addWord(String text) //at least one</div><div> .addWord(String text)</div><div> .sentence(String text) //do we need that?</div><div> .slop() //optional</div><div><br></div><div>//search multiple fields for same value</div><div>.searchInMultipleFields()</div><div> .onField(String field)</div><div> .boostedTo(float) //optional</div><div> .ignoreAnalyzer() //optional</div><div> .onField(String field)</div><div> .forWords(String) //do we need that?</div><div> .forWord(String)</div><div><br></div><div><br></div><div><b>Boolean operations</b></div><div>SealedQueryBuilder contains the boolean methods</div><div><div><br></div><div>.must()<br></div><div> .add( qb.from().to() )</div><div> .add( ... )</div><div>.must().not()</div><div>.should()</div><div><br></div></div><div><br></div><div><b>Works on all queries</b></div><div> .boostedTo()</div><div> .constantScore() </div><div> .filter(Filter) //filter the current query</div><div> .scoreMultipliedByField(field) //FieldScoreQuery + FunctionQuery?? //Not backed</div><div> .createQuery()</div><div><br></div><div><br></div><div><b>Todo</b></div><div>Span*Queries</div><div> </div><div>MultiPhraseQuery - needs to fillup all accepted terms</div><div>FieldScoreQuery</div><div>ValueSourceQuery</div><div>FuzzyLikeThis</div><div>MoreLikeThis</div><div><br></div></span></div></body></html>