2017-05-07 7 views
0

elasticsearch에 filebeat라는 인덱스를 만들었습니다. 로그 데이터는 파일 검색 에이전트에서 elasticsearch로 전송됩니다. value_of_type이라는 특정 열/필드를 기반으로 결과를 필터링하고 싶습니다. PHP API 사용 :올바른 쿼리에도 불구하고 ElasticSearch에서 결과를 반환하지 않습니다.

$json = 
    '{ 
     "query" : { 
      "bool" : { 
       "filter": [ 
        { 
         "term" : 
         { 
          "value_of_type" : "sound" 
         } 
        } 
       ] 
      } 
     } 
    }'; 

그러나 결과는 0입니다. {"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

는 브라우저에서 myurl:9200/filebeat 타격의 결과는 다음과 같습니다

{ 
    "filebeat": { 
     "aliases": {}, 
     "mappings": { 
      "doc": { 
       "properties": { 
        "@timestamp": { 
         "type": "date" 
        }, 
        "beat": { 
         "properties": { 
          "hostname": { 
           "type": "text", 
           "fields": { 
            "keyword": { 
             "type": "keyword", 
             "ignore_above": 256 
            } 
           } 
          }, 
          "name": { 
           "type": "text", 
           "fields": { 
            "keyword": { 
             "type": "keyword", 
             "ignore_above": 256 
            } 
           } 
          }, 
          "version": { 
           "type": "text", 
           "fields": { 
            "keyword": { 
             "type": "keyword", 
             "ignore_above": 256 
            } 
           } 
          } 
         } 
        }, 
        "fields": { 
         "properties": { 
          "node": { 
           "type": "text", 
           "fields": { 
            "keyword": { 
             "type": "keyword", 
             "ignore_above": 256 
            } 
           } 
          }, 
          "value_of_type": { 
           "type": "text", 
           "fields": { 
            "keyword": { 
             "type": "keyword", 
             "ignore_above": 256 
            } 
           } 
          } 
         } 
        }, 
        "input_type": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "message": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "offset": { 
         "type": "long" 
        }, 
        "source": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        }, 
        "type": { 
         "type": "text", 
         "fields": { 
          "keyword": { 
           "type": "keyword", 
           "ignore_above": 256 
          } 
         } 
        } 
       } 
      } 
     }, 
     "settings": { 
      "index": { 
       "creation_date": "1494116541083", 
       "number_of_shards": "5", 
       "number_of_replicas": "1", 
       "uuid": "IdhWgIqiQ-GNrZK3AvCP9g", 
       "version": { 
        "created": "5020199" 
       }, 
       "provided_name": "filebeat" 
      } 
     } 
    } 
} 
+0

데이터가 색인에 있습니다. \t "히트": { \t \t "총"92, \t \t "MAX_SCORE": 1.0, \t \t "히트": [{'myURL이/filebeat/_search' 타격의 결과는 다음과 같은 것입니다 \t \t \t "_index": "filebeat"\t \t \t "_type" "문서" \t \t \t "_id": "AVvgSgz27_8XwAoIUeKd" \t \t \t "_score"1.0 01,235 16,\t \t \t "_source": { \t \t \t \t "@timestamp": "2017-05-07T00 : 23 : 16.000Z" \t \t \t \t "승리": { \t \t \t \t \t "호스트 이름 ":"lorem06 " \t \t \t \t \t"이름 ":"lorem06 " \t \t \t \t \t "버전": "6.0.0 알파 1-git3bcebf6 " \t \t \t \t} \t \t \t \t"필드 "{ \t \t \t \t \t"노드 ":"노드 1 ", \t \t \t \t \t"value_of_type '' '소리 \t \t \t \t}, \t \t \t "input_type": "log", ..... \t \t}, ... .....] –

답변

0

귀하의 질의가 정확하지만 인덱스에서 아무것도 일치하지 않는 : 당신이없는 색인을 생성 문서 올바른 구조. 문서를 일치하는 쿼리에 대한

, 색인에 문서 값 "sound"value_of_type 필드가 있어야합니다 (아래의 샘플 응답으로 반환처럼.)

(모든 필터없이) 간단한 GET /filebeat/_search 쿼리가를 제공해야 결과는 다음과 같습니다 :

{ 
    "took": 28, 
    "timed_out": false, 
    "hits": { 
     "total": N, // the number of documents in your index 
     "max_score": 1, 
     "hits": [ 
     ... 
     { 
      "_index": "filebeat", 
      "_type": "some_doc_type", 
      "_id": "some_id", 
      "_score": 1, 
      "_source": { 
       ... 
       "value_of_type": "sound", // that's what you query will match 
       ... 
      } 
    ] 
} 
+0

감사합니다. 다음 변경 사항으로 업데이트 된 쿼리가 작동합니다. ' '용어 : { "fields.value_of_type": "소리" } –