2017-11-10 102 views
5

ElasticSearch 5.6.3'da iç içe geçmiş belgelerin toplanmasıyla ilgili bir sorunum var.İç içe geçmiş belgelerin toplamalarını ElasticSearch içinde alma 5.6.3, Lucene istisnasına yol açar

Benim sorgu aşağıdaki şekilde yapılandırılmıştır: beklendiği gibi

query 
    aggs 
    |_filter 
    |_nested 
     |_term 
     |_top-hits 

Ben olmayan bir iç içe alanda toplanmasını çalışırsanız (ve tabii kaldırıldı iç içe AGG ile), her şey çalışıyor. şimdi yapılandırılmıştır gibi, ben Lucene bir durum alırsınız: Child query must not match same docs with parent filter. Combine them as must clauses (+) to find a problem doc. docId=2147483647, class org.apache.lucene.search.ConstantScoreScorer

Bu istisna değil ElasticSearch 2.4.6 tetiklenir olduğunu.

Toplamaları farklı bir şekilde yapılandırmaya çalıştım, ancak istenen sonuçları veren ve çalıştıran bir kombinasyonla gelemedim.

"recording": { 
    "dynamic": "strict", 
    "_all" : { 
    "enabled" : false 
    }, 
    "properties": { 
    "id": { 
     "type": "integer" 
    }, 
    "soloists": { 
     "properties": { 
     "type": "nested", 
     "person": { 
      "properties": { 
      "id": { 
      "type": "integer" 
      }, 
      "name": { 
       "type": "string", 
       "index": "not_analyzed" 
      } 
     } 
     } 
    }, 
    "work": { 
     "id": { 
     "type": integer 
     }, 
     "title": { 
     "type": "string", 
     "index": "not_analyzed" 
     } 
    } 
} 

Ve sorguda kendisi: Herhangi bir yardım son derece mutluluk duyacağız

{ 
    "query": {}, 
    "aggs": { 
    "my_top_results": { 
     "global": {}, 
     "aggs": { 
     "my_filter_agg": { 
      "filter": { 
      "bool": { 
       "must": [ 
       { 
        "bool": { 
        "should": [ 
         { 
         "nested": { 
          "path": "soloists", 
          "query": { 
          "bool": { 
           "must": { 
           "match": { 
            "soloists.person.id": 77957 
           } 
           } 
          } 
          } 
         } 
         } 
        ] 
        } 
       } 
       ] 
      } 
      }, 
      "aggs": { 
      "my_nested_agg": { 
       "nested": { 
       "path": "soloists" 
       }, 
       "aggs": { 
       "my_terms_agg": { 
        "term": { 
        "field": "soloists.person.id", 
        "size": 10 
        } 
        "aggs": { 
        "my_top_hits_agg": { 
         "size": 1, 
         "_source": { 
         "include": [ 
          "soloists.person.id", 
          "soloists.person.name" 
         ] 
         } 
        } 
        } 
       } 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 

haritalama neye benzediğini

budur.

bazı bağlantılar Ben tökezledi genelinde bir çözüm ararken:

+1

Hey Claudiu, ilk şey şu ki 'my_top_hits_agg' doğru yerde değil,' my_terms_agg' topluluğunun içine yerleştirilmeli ve 'top_hits' anahtar sözcüğü eksik değil, değil mi? Sorgunun işe yaramadığına şaşırdım. – Val

+0

Hey @Val! Böyle bir buluşma yolu. Tamamen haklısın - benim tarafımda bir kopya-yapıştır hatasıydı. Sorguyu düzelttim, ancak sorun devam ediyor ... – cvursache

+0

Illy ;-) Filtreyi, en az gereksinim duyulana göre basitleştirirseniz, yani sadece iç içe filtre (bool/must + bool/should part)) ne olursa olsun ne olur? – Val

cevap

3

eşlemenizde ve sorgular bazı yazım hataları vardır:

Burada, bir Elasticsearch 5.6.3 örneğinde kullanıldığında herhangi bir hatayı tetiklemeyen bazı sabit komutlar bulunmaktadır.

Kibana'ya veya bir Linux terminaline kopyalayıp yapıştırabilirsiniz (bu durumda ilk satırı düzenlemeniz gerekir) ve bunları Elasticsearch örneğinizde test edebilirsiniz. biz endeksinin kesin ayarları ve eşleme kontrol edebilirsiniz böylece bu sorgular çalışır ancak dizine uygulanmadığı zaman ise

HOST=10.225.0.2:9200 

curl -XPUT "http://$HOST/an_index" 

curl -XPUT "http://$HOST/an_index/recording/_mapping" -H 'Content-Type: application/json' -d' 
{ 
    "dynamic": "strict", 
    "_all": { 
    "enabled": false 
    }, 
    "properties": { 
    "id": { 
     "type": "integer" 
    }, 
    "soloists": { 
     "type": "nested", 
     "properties": { 
     "person": { 
      "properties": { 
      "id": { 
       "type": "integer" 
      }, 
      "name": { 
       "type": "string", 
       "index": "not_analyzed" 
      } 
      } 
     } 
     } 
    }, 
    "work": { 
     "properties": { 
     "id": { 
      "type": "integer" 
     }, 
     "title": { 
      "type": "string", 
      "index": "not_analyzed" 
     } 
     } 
    } 
    } 
}' 

curl -XPOST "http://$HOST/an_index/recording/1" -H 'Content-Type: application/json' -d' 
{ 
    "id": 0, 
    "soloists": [ 
    { 
     "person": { 
     "id": 77957, 
     "name": "John doe" 
     } 
    }, 
    { 
     "person": { 
     "id": 1, 
     "name": "Jane smith" 
     } 
    } 
    ], 
    "work": { 
    "id": 0, 
    "title": "Test" 
    } 
}' 

curl -XGET "http://$HOST/an_index/recording/_search?pretty" -H 'Content-Type: application/json' -d' 
{ 
    "size": 0, 
    "aggs": { 
    "my_top_results": { 
     "global": {}, 
     "aggs": { 
     "my_filter_agg": { 
      "filter": { 
      "bool": { 
       "must": [ 
       { 
        "bool": { 
        "should": [ 
         { 
         "nested": { 
          "path": "soloists", 
          "query": { 
          "bool": { 
           "must": { 
           "match": { 
            "soloists.person.id": 77957 
           } 
           } 
          } 
          } 
         } 
         } 
        ] 
        } 
       } 
       ] 
      } 
      }, 
      "aggs": { 
      "my_nested_agg": { 
       "nested": { 
       "path": "soloists" 
       }, 
       "aggs": { 
       "my_terms_agg": { 
        "terms": { 
        "field": "soloists.person.id", 
        "size": 10 
        }, 
        "aggs": { 
        "my_top_hits_agg": { 
         "top_hits": { 
         "size": 1, 
         "_source": { 
          "include": [ 
          "soloists.person.id", 
          "soloists.person.name" 
          ] 
         } 
         } 
        } 
        } 
       } 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
}' 

, sen curl -XGET "http://$HOST/your_index_name" çıkışında soruyla güncellemek misin? Bu tür bir hata, aynı dizindeki türler arasındaki çakışma nedeniyle olabilir. Cevabımı buna göre güncelleyeceğim.

+0

Teşekkürler @Pandawan! Sonunda sorgulamayı iş mantığımıza uyacak şekilde tamamen farklı bir şekilde çözdüm. Her durumda, cevap için teşekkürler ve gecikmiş yanıt için özür dilerim. – cvursache

İlgili konular