2016-01-20 3 views
0

Я установил elasticsearch 2.1.1 на кластере из 3 узлов. Ниже мой указательный с 2-х типовhas_parent и has_child query всегда возвращает пустые результаты: ElasticSearch 2.1.1

{ 
"log-aggregation": { 
    "mappings": { 
     "application-logs": { 
      "_all": { 
       "enabled": true 
      }, 
      "_parent": { 
       "type": "webserver-logs" 
      }, 
      "_routing": { 
       "required": true 
      }, 
      "properties": { 
       "localhost": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       }, 
       "log_level": { 
        "type": "string", 
        "include_in_all": true 
       }, 
       "logging_class": { 
        "type": "string", 
        "include_in_all": true 
       }, 
       "logging_message": { 
        "type": "string", 
        "index": "no", 
        "include_in_all": true 
       }, 
       "origin": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       },      
       "request_date": { 
        "type": "date", 
        "format": "YYYY-MM-dd HH:mm:ss,SSS", 
        "include_in_all": true 
       }, 
       "request_time": { 
        "type": "long", 
        "include_in_all": true 
       }, 
       "request_timestamp": { 
        "type": "date", 
        "format": "epoch_millis", 
        "include_in_all": true 
       }, 
       "response_time": { 
        "type": "string" 
       }, 
       "response_timestamp": { 
        "type": "date", 
        "format": "epoch_millis", 
        "include_in_all": true 
       }, 
       "unique_id": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       } 
      } 
     }, 
     "webserver-logs": { 
      "_all": { 
       "enabled": true 
      }, 
      "_routing": { 
       "required": true 
      }, 
      "properties": { 
       "accept_type": { 
        "type": "string", 
        "index": "no", 
        "include_in_all": true 
       }, 
       "content_type": { 
        "type": "string", 
        "index": "no", 
        "include_in_all": true 
       }, 
       "http_method": { 
        "type": "string", 
        "include_in_all": true 
       }, 
       "http_protocol": { 
        "type": "string" 
       }, 
       "http_status": { 
        "type": "long", 
        "index": "analyzed", 
        "include_in_all": true 
       }, 
       "http_url": { 
        "type": "string" 
       }, 
       "localhost": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       }, 
       "origin": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       }, 
       "referrer": { 
        "type": "string", 
        "index": "no", 
        "include_in_all": true 
       }, 
       "request_timestamp": { 
        "type": "date", 
        "format": "epoch_millis", 
        "include_in_all": true 
       }, 
       "response_size": { 
        "type": "short", 
        "index": "no", 
        "include_in_all": true 
       }, 
       "timestamp": { 
        "type": "string" 
       }, 
       "unique_id": { 
        "type": "string", 
        "index": "not_analyzed", 
        "include_in_all": true 
       }, 
       "useragent": { 
        "type": "string", 
        "index": "no", 
        "include_in_all": true 
       } 
      } 
     } 
    } 
} 

}

Ниже приведены документы, я индексироваться.

POST на http://SERVERNAME:9200/log-aggregation/webserver-logs?routing=VlN6VQoEFHAAAEcxAUUAAAAC

{ 

"локальный": "svcdev104.imagitas.com", "происхождение": "10.4.30.112", "unique_id": "VlN6VQoEFHAAAEcxAUUAAAAC", "метка" : "1448311381504", "http_method": "POST", "HTTP_URL": "/ регистрация/v1/сохранить", "http_protocol": "HTTP/1.1", "HTTP_STATUS": "500", " response_size ":" 137 ", " accept_type ":" application/json ", " conte nt_type ":" application/json ", " referrer ":" - ", " useragent ":" Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537,36 (KHTML, как Gecko) Chrome/46.0.2490.86 Safari/537,36" }

ПОСТ http://SERVERNAME:9200/log-aggregation/application-logs?routing=VlN6VQoEFHAAAEcxAUUAAAAC&parent=VlN6VQoEFHAAAEcxAUUAAAAC

{ 

"локальный": "svcdev104.imagitas.com", «Происхождение ": "хром-расширение: // aejoelaoggembcahagimdiliamlcdmfm", "unique_id": "VlN6VQoEFHAAAEcxAUUAAAAC", "request_timestamp": "1448311331605", "response_timestamp": "1448311381609", "response_time": "4", " request_date ":" 2015-11-23 12: 53: 01,605 ", " log_lev эль ": "WARN", "logging_class": "LoggingResponseInterceptor", "logging_message": "Сохранение регистрации данных не удалось ....." }

Теперь я бегу has_child и has_parent запрос и не получить какой-либо результат. Я запрашивая каждый тип и получать результаты, хотя, но не тогда, когда я бегу has_child и has_parent запрос

Вот пример запросов POST http://SERVERNAME:9200/log-aggregation/application-logs/_search

{ 

"запрос": { "has_parent": { "Тип": "WebServer-журналы", "запрос": { "совпадение": { "HTTP_STATUS": "500" }} }} }

Любая помощь будет высоко оценена. Спасибо Sri

ответ

1

Вам необходимо установить _id родителя, иначе ребенок не будет отображаться на нем.

Таким образом, ваш первый вкладыш документ должен выглядеть следующим образом:

POST http://SERVERNAME:9200/log-aggregation/webserver-logs/VlN6VQoEFHAAAEcxAUUAAAAC/?routing=VlN6VQoEFHAAAEcxAUUAAAAC 
{ 
    "localhost": "svcdev104.imagitas.com", 
    "origin": "10.4.30.112", 
    "unique_id": "VlN6VQoEFHAAAEcxAUUAAAAC", 
    "timestamp": "1448311381504", 
    "http_method": "POST", 
    "http_url": "/registration/v1/save", 
    "http_protocol": "HTTP/1.1", 
    "http_status": "500", 
    "response_size": "137", 
    "accept_type": "application/json", 
    "content_type": "application/json", 
    "referrer": "-", 
    "useragent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" 
} 

И тогда ваш запрос будет работать.

Вот код, который я использовал, чтобы проверить:

http://sense.qbox.io/gist/ff5d4fcd6bca62853f2d506e0b81a7290ee727d7

+0

Я вижу проблему сейчас. Благодарю. Тем не менее, я ищу, чтобы Ids автогенерировали и связывали unique_ids в этих двух типах. Как мне это сделать? Я обязательно выберу вам ответ как ответ Еще раз спасибо –

+0

Я не вижу, как это сделать, если вы не добавите запрос между ними, который возвращает нового родителя, чтобы получить его идентификатор. –

+0

Согласовано. Спасибо за вашу помощь. Ценить это. –

Смежные вопросы