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 .
}
}

我正在尝试做同样的事情,但在小精灵中:

g.withSideEffect('Neptune#fts.endpoint', '...')
.V().has(['name', 'company'], 'Neptune#fts term*')

这显然是行不通的。现在我可以像这样使用通配符:

g.withSideEffect('Neptune#fts.endpoint', '...')
.V().has('*', 'Neptune#fts term*')

但是现在我正在匹配所有字段,但它失败了,因为我们的索引太多了。(我认为有 1,024 个限制。

知道如何指定要在 Gremlin 查询中搜索的字段列表吗?

同时,我发现了一种解决方法,该解决方法有效但不是很干净:

可以将查询设置为使用query_string格式,如下所示:

.withSideEffect("Neptune#fts.queryType", "query_string")

它对语法的宽容度会降低,但这意味着您可以在查询中搜索字段:

field1:foo AND field2:bar

现在有了 Neptune 就不那么简单了,因为你的字段名称不仅仅是field1field2,但它们的格式是这样的:

predicates: {
field1: {
value: "..."
},
field2: {
value: "..."
}
}

没关系,你只需要修改查询:

predicates.field1.value:foo AND predicates.field2.value:bar

以下是我如何"确保某些字段与术语匹配">

predicates.field1.value:<term> OR predicates.field2.value:<term>

最新更新