You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by dsmiley <gi...@git.apache.org> on 2017/12/01 22:04:29 UTC

[GitHub] lucene-solr pull request #275: SOLR-11662: Configurable query when terms ove...

Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/275#discussion_r154457666
  
    --- Diff: solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java ---
    @@ -539,6 +591,27 @@ protected Query newRegexpQuery(Term regexp) {
         return query;
       }
     
    +  @Override
    +  protected Query newSynonymQuery(Term terms[]) {
    +    switch (synonymQueryStyle) {
    +      case PICK_BEST:
    +        List<Query> currPosnClauses = new ArrayList<Query>(terms.length);
    +        for (Term term : terms) {
    +          currPosnClauses.add(newTermQuery(term));
    +        }
    +        DisjunctionMaxQuery dm = new DisjunctionMaxQuery(currPosnClauses, 0.0f);
    +        return dm;
    +      case AS_DISTINCT_TERMS:
    +        BooleanQuery.Builder builder = new BooleanQuery.Builder();
    +        for (Term term : terms) {
    +          builder.add(newTermQuery(term), BooleanClause.Occur.SHOULD);
    +        }
    +        return builder.build();
    +      default:
    --- End diff --
    
    What I meant to say in my previous review here is that you would have a case statement for AS_SAME_TERM and then to satisfy Java, add a default that throws an assertion error.  This way we see all 3 enum vals with their own case, which I think is easier to understand/maintain.  Oh, are you're doing this to handle "null"?  Hmm. Maybe put the case immediately before your current "default"?  Or prevent null in the first place?  Either I guess... nulls are unfortunate; I like to avoid them.  Notice TextField has primitives for some of its other settings; it'd be nice if likewise we had a non-null value for TextField.synonymQueryStyle.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org