2014-12-04 4 views
8

ES 쿼리 시스템의 근본적인 이해에 많은 문제가 있습니다.elasticsearch가 너무 많은 결과를 얻는데 도움이 필요합니다.

나는 예를 들어 다음 쿼리를 가지고 :

{ 
    "size": 0, 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "term": { 
      "referer": "www.xx.yy.com" 
      } 
     }, 
     { 
      "range": { 
      "@timestamp": { 
       "gte": "now", 
       "lt": "now-1h" 
      } 
      } 
     } 
     ] 
    } 
    }, 
    "aggs": { 
    "interval": { 
     "date_histogram": { 
     "field": "@timestamp", 
     "interval": "0.5h" 
     }, 
     "aggs": { 
     "what": { 
      "cardinality": { 
      "field": "host" 
      } 
     } 
     } 
    } 
    } 
} 
너무 많은 결과를 얻을 요청

:

{ 
    "size": 0, 
    "filter": { 
    "and": [ 
     { 
     "term": { 
      "referer": "www.geoportail.gouv.fr" 
     } 
     }, 
     { 
     "range": { 
      "@timestamp": { 
      "from": "2014-10-04", 
      "to": "2014-10-05" 
      } 
     } 
     } 
    ] 
    }, 
    "aggs": { 
    "interval": { 
     "date_histogram": { 
     "field": "@timestamp", 
     "interval": "0.5h" 
     }, 
     "aggs": { 
     "what": { 
      "cardinality": { 
      "field": "host" 
      } 
     } 
     } 
    } 
    } 
} 

I : 그 요청을 tryied했습니다

"status" : 500, "reason" : "ElasticsearchException[org.elasticsearch.common.breaker.CircuitBreakingException: Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; nested: UncheckedExecutionException[org.elasticsearch.common.breaker.CircuitBreakingException: Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; nested: CircuitBreakingException[Data too large, data for field [@timestamp] would be larger than limit of [3200306380/2.9gb]]; "

을 올바른 결과를 얻을 수 있도록 데이터를 필터링하고 싶습니다. 어떤 도움이라도 대단히 감사하겠습니다!

답변

12

해결책을 찾았습니다. 이상하게 보입니다. 내가 adviced dimzak 다음 캐시 삭제했습니다

curl --noproxy localhost -XPOST "http://localhost:9200/_cache/clear" 

그럼 내가 대신 올리으로 쿼리의 필터링을 사용 제안 :

이 가
{ 
    "size": 0, 
    "query": { 
    "filtered": { 
     "query": { 
     "term": { 
      "referer": "www.xx.yy.fr" 
     } 
     }, 
     "filter" : { 
     "range": { 
      "@timestamp": { 
      "from": "2014-10-04T00:00", 
      "to": "2014-10-05T00:00" 
      } 
     } 
     } 
    } 
    }, 
    "aggs": { 
    "interval": { 
    "date_histogram": { 
    "field": "@timestamp", 
    "interval": "0.5h" 
    }, 
    "aggs": { 
    "what": { 
     "cardinality": { 
     "field": "host" 
     } 
    } 
    } 
    } 
    } 
} 

내가 당신에게 ansxwer 모두를 줄 수 없다, 내가 생각 dimzak이 그것을받을 자격이 가장 좋은,하지만 두 사람까지 엄지 손가락 :

+0

또 다른 훨씬 더 깨끗한 솔루션이 생겼습니다. 테스트를 마쳤을 때 알려 드리겠습니다. –

+0

Alexandre Mélard 청소기 솔루션은 무엇입니까? – spuder

+1

죄송합니다. 그 시간이 더 이상 없었 습니다만, 그 문제를 놓치지 않으면 안됩니다. 그러나 무언가를 최대한 빨리 게시하려고합니다. –

6

캐시를 먼저 지운 다음 here과 같이 위 쿼리를 실행할 수 있습니다.

또 다른 해결책이 간격을 제거하거나 조회에서 시간 범위를 줄일 수 있습니다

...

내 가장 좋은 방법은 첫째 중 캐시 삭제, 또는 사용 elasticsearch하기 위해 (더 here)

4

더 많은 메모리를 할당 할 것 필터는 성능을 향상시킬 것입니다 :

{ 
    "size": 0, 
    "query": { 
    "filtered": { 
     "query": { 
      "term": { 
      "referer": "www.xx.yy.com" 
      } 
     }, 
     "filter" : {"range": { 
      "@timestamp": { "gte": "now", "lt": "now-1h" 
       } 
      } 
      } 
     } 
    }, 
    "aggs": { 
    "interval": { 
     "date_histogram": { 
     "field": "@timestamp", 
     "interval": "0.5h" 
     }, 
     "aggs": { 
     "what": { 
      "cardinality": { 
      "field": "host" 
      } 
     } 
     } 
    } 
    } 
} 

또한 date range 날짜 히스토그램보다 더 나은 것을 찾을 수 있습니다 - 당신은 양동이를 직접 정의 할 필요가있다.

은 분석되는 referer 필드입니까? 또는 정확히 일치하는지 알고 싶다면 not_analyzed으로 설정하십시오.

hostname 필드에 많은 카디널리티가 있습니까? 값을 사전 해시 해 보셨습니까?

+0

쿼리를 실행할 때 SearchPhaseExecutionException이 발생합니다. –

+0

ok, 그냥 필터 주위에 중괄호가 누락되었습니다. –

+0

사과 - 중괄호를 추가하는 코드를 업데이트했습니다. –

관련 문제