When type is text, setting "index" to "not_analyzed" does not seem to work

"properties": {
  "columns": {
    "properties": {
      "id": {
        "type": "keyword",
        "index": "not_analyzed"
      },
      "name": {
        "type": "keyword",
        "index": "not_analyzed"
      },
      "siteId": {
        "type": "keyword",
        "index": "not_analyzed"
      }
    }
  },
  "text": {
    "type": "text",
    "store": "false",
    "analyzer": "hanlp",
    "fields": {
      "keyword": {
        "type": "text",
        "index": "not_analyzed",
        "fielddata": "true"
      }
    }
  }
}

In order to achieve fuzzy queries, I use the following ways to query:

GET/book_page/book_page/_search
{
      "from": 0,
      "size": 10,
      "query": {
        "bool": {
          "must": [
            {
              "script": {
                "script": {
                  "inline": "doc['text_nlp_sore.keyword'].value!=null&&doc['text_nlp_sore.keyword'].value.indexOf(params.a)!=-1",
                  "lang": "painless",
                  "params": {
                    "a": "中文"
                  }
                }
              }
            }
          ]
        }
      },
      "sort": [
        {
          "_script": {
            "script": {
              "inline": "String myText=doc['text_nlp_sore.keyword'].value;if(myText!=null){int count=0;int index=-1;while((index=myText.indexOf(params.a))!=-1){count++;myText=myText.substring(index+params.a.length())}return Math.log(count);}else{return 0;}",
              "lang": "painless",
              "params": {
                "a": "中文"
              }
            },
            "type": "string",
            "order": "desc"
          }
        },
        {
          "bookDate_date_sore": {
            "order": "desc"
          }
        }
      ],
      "highlight": {
        "fields": {
          
        }
      }
    }

But what search does not come out, I doubt that the doc['text_nlp_sore.keyword'].value value is participle? But I clearly set up "index": "not_analyzed". So I want to know if I have made any mistake in that part, or did my doc get the wrong way, please tell me. Thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.