[Elasticsearch] 특정 field에 포함되어 있는 문자열 검색 (contains)

error field에 Exception 문자열이 포함되어 있는 모든 데이터 검색

 

POST http://localhost:9200/index-2023-07-19/_search

{
    "query": {
        "query_string": {
            "default_field": "error",
            "query": "*Exception*"
        }
    }
}
{
  "took": 429,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "index-2023-07-19",
        "_id": "TkBUR4kB0QMiyzEF7slT",
        "_score": 1.0,
        "_ignored": [],
        "_source": {
          "error": "InvalidDataTypeException(message)"
        }
      }
    ]
  }
}

 

출처: https://stackoverflow.com/questions/52531342/contains-query-or-partial-matching-in-elasticsearch