Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-70316

boolean like parameter in addTerm method is not used for wildcard searches

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Master
    • Fix Version/s: None
    • Component/s: Search Infrastructure
    • Labels:

      Description

      In previous search versions, the "like" parameter is normally used for wildcard searches. In master/70x, portal is automatically using wildcard searches and giving boosting for matches. As a developer, if I'm using "addTerm" with a false "like" parameter, it should do a QueryTerm similar to an addExactTerm() query rather than a FullText > Phrase search.

      GitId: 5448a6e95e2f429b27725fa9b044075c119d549f
      Master BooleanQueryImpl:

      	@Override
      	public Query addTerm(
      		String field, String value, boolean like,
      		BooleanClauseOccur booleanClauseOccur) {
      
      		Query query = FieldQueryFactoryUtil.createQuery(
      			field, value, like, false);
      
      		return add(query, booleanClauseOccur);
      	}
      

      Master FieldQueryFactoryImpl:

      	@Override
      	public Query createQuery(
      		String fieldName, String keywords, boolean like,
      		boolean splitKeywords) {
      
      		FieldQueryBuilder fieldQueryBuilder = getQueryBuilder(fieldName);
      
      		return fieldQueryBuilder.build(fieldName, keywords);
      	}
      

      Additional Notes:

      • currently it's not possible to remove the boosting from the search query, see below for example
        "bool" : {
                    "must" : {
                      "bool" : {
                        "should" : [ {
                          "match" : {
                            "companyId" : {
                              "query" : "10157"
                            }
                          }
                        }, {
                          "match" : {
                            "companyId" : {
                              "query" : "10157",
                              "type" : "phrase_prefix"
                            }
                          }
                        } ]
                      }
                    },
                    "should" : {
                      "match" : {
                        "companyId" : {
                          "query" : "10157",
                          "type" : "phrase",
                          "boost" : 2.0
                        }
                      }
                    }
        
      • if "like" is false and can be a termQuery rather than a full text search, can look similar to:
        "should" : {
                      "term" : {
                        "entryClassName" : "com.liferay.portlet.journal.model.JournalArticle"
                      }
                    }
        
      • there's also no method to do a termQuery with a "must" or a "must_not" clause so most people rely on addTerm(), below is from BooleanQueryImpl
        	@Override
        	public Query addExactTerm(String field, String value) {
        		TermQueryImpl termQuery = new TermQueryImpl(
        			new QueryTermImpl(field, String.valueOf(value)));
        
        		return add(termQuery, BooleanClauseOccur.SHOULD);
        	}
        

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                1 year, 42 weeks ago

                Packages

                Version Package