Using special characters to search the text that is contained \n character


(Bruce Lo) #1

I using (**&(&A search the text with plugin smartcn, then it can search the result.
But my wish is it doesn't show the result when using this query. Is there any solutions? Thanks.

my index, type:

curl -XPUT 'http://localhost:9200/kkk?pretty' -d '{
    "mappings":{
        "ddd":{
            "properties":{
                "publish_content":{
                    "type": "text",
                    "analyzer": "smartcn"
                }
            }
        }
    }
}'

the text:

curl -XPUT 'localhost:9200/kkk/ddd/1?pretty&pretty' -H 'Content-Type: application/json' -d'
{
  "publish_content": "12.27日晚上差不多8点多左右,一对夫妇就过来了,说想换台手机。\n\nA\n听说xxx上市了?那xxx大的那个什么时候上市?\n\nB\n这个是这个月底30号上市。"
}
'

search:

curl -XPOST 'http://localhost:9200/kkk/ddd/_search?pretty' -d '{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "publish_content": {
              "query": "(**&(&A",
              "analyzer" : "smartcn"
            }
          }
        }
      ]
    }
  }
}'

it will show reuslt:

{
  "took" : 17,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.23398489,
    "hits" : [
      {
        "_index" : "kkk",
        "_type" : "ddd",
        "_id" : "1",
        "_score" : 0.23398489,
        "_source" : {
          "publish_content" : "12.27日晚上差不多8点多左右,一对夫妇就过来了,说想换台手机。\n\nA\n听说xxx上市了?那xxx大的那个什么时候上市?\n\nB\n这个是这个月底30号上市。"
        }
      }
    ]
  }
}

(system) #2

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