Amazon Neptune 全文搜索 - 指定字段
Amazon Neptune Full Text Search - specify fields
因此 SPARQL documentation 包含如何指定要搜索的多个字段的示例:
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 .
}
}
我正在尝试做同样的事情,但在 Gremlin 中:
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 就不那么简单了,因为您的字段名称不只是 field1
、field2
,而是格式如下:
predicates: {
field1: {
value: "..."
},
field2: {
value: "..."
}
}
没关系,您只需要修改查询:
predicates.field1.value:foo AND predicates.field2.value:bar
这是我的做法"make sure that some of the fields match term":
predicates.field1.value:<term> OR predicates.field2.value:<term>
因此 SPARQL documentation 包含如何指定要搜索的多个字段的示例:
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 .
}
}
我正在尝试做同样的事情,但在 Gremlin 中:
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 就不那么简单了,因为您的字段名称不只是 field1
、field2
,而是格式如下:
predicates: {
field1: {
value: "..."
},
field2: {
value: "..."
}
}
没关系,您只需要修改查询:
predicates.field1.value:foo AND predicates.field2.value:bar
这是我的做法"make sure that some of the fields match term":
predicates.field1.value:<term> OR predicates.field2.value:<term>