【发布时间】:2017-03-20 00:39:57
【问题描述】:
我将 Elasticsearch 与 python 库一起使用,当对象变得有点复杂时,我在使用搜索查询时遇到了问题。我的索引中有这样的对象:
{
"id" : 120,
"name": bob,
"shared_status": {
"post_id": 123456789,
"text": "This is a sample",
"urls" : [
{
"url": "http://test.1.com",
"displayed_url": "test.1.com"
},
{
"url": "http://blabla.com",
"displayed_url": "blabla.com"
}
]
}
}
现在我想做一个查询,仅当其中一个显示的 URL 中有一个子字符串“test”并且主文档中有一个字段“text”时才会返回这个文档。所以我做了这个查询:
{
"query": {
"bool": {
"must": [
{"exists": {"field": "text"}}
]
}
}
}
}
但我不知道要为该部分添加什么查询:one of the displayed URL's a substring "test"
这可能吗?列表上的迭代是如何工作的?
【问题讨论】:
-
有可能。请提供 _mapping 的输出:elastic.co/guide/en/elasticsearch/reference/current/…
-
问题是关于查询弹性搜索而不是在 JSON 上迭代
-
@rahulroc 我用一个假的例子简化了情况,但我的应用程序是关于来自 API twitter 的推文。而且我的映射中没有为这些字段定义映射。
-
@mel 由于您没有提供显式映射,ES 假设一些基于输入数据的映射类型,答案中的更多详细信息
标签: elasticsearch full-text-search