Voj*_*jto 6 elasticsearch gremlin amazon-neptune
因此,SPARQL 文档包含如何指定多个要搜索的字段的示例:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX neptune-fts: <http://aws.amazon.com/neptune/vocab/v01/services/fts#>
SELECT * WHERE {
SERVICE neptune-fts:search {
neptune-fts:config neptune-fts:endpoint 'http://your-es-endpoint.com' .
neptune-fts:config neptune-fts:queryType 'query_string' .
neptune-fts:config neptune-fts:query 'mikael~ OR rondelli' .
neptune-fts:config neptune-fts:field foaf:name .
neptune-fts:config neptune-fts:field foaf:surname .
neptune-fts:config neptune-fts:return ?res .
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试做同样的事情,但在 Gremlin 中:
g.withSideEffect('Neptune#fts.endpoint', '...')
.V().has(['name', 'company'], 'Neptune#fts term*')
Run Code Online (Sandbox Code Playgroud)
这显然行不通。现在我可以像这样使用通配符:
g.withSideEffect('Neptune#fts.endpoint', '...')
.V().has('*', 'Neptune#fts term*')
Run Code Online (Sandbox Code Playgroud)
但是现在我正在匹配所有字段,但它失败了,因为我们的索引太多了。(我认为限制为 1,024。)
知道如何指定要在 Gremlin 查询中搜索的字段列表吗?
同时我找到了一个解决方法,它有效但不是很干净:
您可以将查询设置为使用如下query_string格式:
.withSideEffect("Neptune#fts.queryType", "query_string")
它对语法的宽容度会降低,但这意味着您可以在查询中搜索字段:
field1:foo AND field2:bar
现在使用 Neptune 就不是那么简单了,因为您的字段名称不仅仅是field1, field2,而且它们的格式如下:
predicates: {
field1: {
value: "..."
},
field2: {
value: "..."
}
}
Run Code Online (Sandbox Code Playgroud)
没关系,您只需要修改查询:
predicates.field1.value:foo AND predicates.field2.value:bar
这就是我如何“确保某些字段与术语匹配”:
predicates.field1.value:<term> OR predicates.field2.value:<term>
| 归档时间: |
|
| 查看次数: |
398 次 |
| 最近记录: |