Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-39592

[N1QL+FTS] Mandate keyword analyzer for queries that don't use an analyzer



    • Untriaged
    • 1
    • Unknown


      The fields for the following queries need to be set up with "keyword" analyzer within the index for the query to be sargable for the index:

      • TermQuery
      • PhraseQuery
      • MultiPhraseQuery
      • FuzzyQuery
      • PrefixQuery
      • RegexpQuery
      • WildcardQuery

      This change is necessary to assure consistent results during a covering and a non-covering query scenario when no index options are specified within the SEARCH(..) function.
      This will also change the behavior for the above mentioned queries, but in a good away - that the user will always see the same result with and without validation.

      Note: this issue in validation (with a non-covered query) could still happen over certain data with must_not (NEG) over Match and MatchPhrase queries when the user has an index with a field using non-standard analyzer and does NOT specify the index name within options or the analyzer within the query.

      See: https://forums.couchbase.com/t/n1ql-search-query-result-varies-depending-on-selected-fields/

      Here's an example:

      Index: "field": "dept", "analyzer": "keyword" Data: {"dept": "Pre-sales"} 
      Query: SELECT * from keyspace WHERE SEARCH(keyspace, "-dept:Sales");


      • Search phase would return the document as the match query (which uses the keyword analyzer) wouldn't match Sales with Pre-sales.
      • However, during the validation phase - since there's no index context, or analyzer explicitly specified for the match query - the default analyzer is used which causes the document to not be returned for the query.

      The workarounds here are these queries ..

      SELECT * from keyspace WHERE SEARCH(keyspace, "-dept:Sales", {"index":"index_name"});

      SELECT *
      FROM keyspace
      WHERE SEARCH(keyspace, {"must_not": {"disjuncts":[{"field": "dept", "match": "Sales", "analyzer":"keyword"}]}});



        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



              abhinav Abhi Dangeti
              abhinav Abhi Dangeti
              0 Vote for this issue
              4 Start watching this issue



                Gerrit Reviews