2012-11-20 29 views
0

,当我有麻烦访问我Elasticsearch指数 一些多值数组我使用的查询中 retrieving the multivalued array from elasticsearch 但我得到空poiter例外,我的一些索引中的文档,其中用于数组给定的搜索存在,当我使用的queryString查询,而不是MATCH_ALL。这occures空指针异常检索多值阵列场

{ 
took: 3 
timed_out: false 
_shards: { 
    total: 2 
    successful: 1 
    failed: 1 
    failures: [ 
     { 
      status: 500 
      reason: NullPointerException[null] 
     } 
    ] 
} 

我查询

{ 
"query":{ 
    "query_string":{ 
    "query":"report","default_field":"Content" 
} 
}, 
"script_fields": { 
"entity_facets": { 
"script": "result=[];foreach(facet : _source.Categories.Types.Events)  

{if(facet.event==event) result.add(facet);} result", 
"params": { 
"event":"AnalystEvent" 
    } 
    } 
} 

}

编辑: 我有一个索引 https://gist.github.com/4129488 我得到了通过运行查询

{ 
    "from": "0", 
    "size": "100", 
    "query": { 
    "bool": { 
    "must": [ 
    { 
    "bool": { 
    "must": [ 
    { 
    "query_string": { 
    "query": "confronted", 
    "default_field":"Content" 
    } 
    }, 
    { 
    "range": { 
    "actualTimeStamp": { 
    "from": "23-07-2012 10:04:52", 
    "to": "23-09-2012 10:04:52" 
    } 
} 
} 
    ] 
} 
}, 
{ 
    "bool": { 
    "should": [ 
    { 
    "fuzzy": { 
    "SourceName": { 
    "value": "Economic_Times" 
    } 
    } 
    }, 
    { 
    "fuzzy": { 
    "SourceName": { 
    "value": "reuters" 
    } 
    } 
    } 
] 
} 
} 
] 
} 
} 
} 

但我没有”上面的查询使用第脚本场时得到这个指标!

+0

你好家伙有什么想法吗? – user1790894

回答

0

你可能有一条记录,它不存储_source,或者它的_source没有类别,或者类别没有任何类型或类型没有任何事件。只需添加if语句来检查这些条件。

+0

感谢您的回复..我会仔细检查它 – user1790894

+0

我检查了我的索引,没有任何错误,正如你所说。我编辑了我的帖子请求审查。预计你的帮助排序问题:( – user1790894

+0

我测试了它与您记录和它不会失败https://gist.github.com/58e7a59e69a39b8d361c – imotov