

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Neptune 全文檢索搜尋查詢中使用 Apache Lucene 查詢語法
<a name="full-text-search-lucene"></a>

OpenSearch 支援將 [Apache Lucene 語法](https://lucene.apache.org/core/8_9_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description)用於 query\_string 查詢。這對在查詢中傳遞多個篩選條件特別有用。

Neptune 會使用巢狀結構，儲存 OpenSearch 文件中的屬性 (請參閱 [Neptune 全文檢索搜尋資料模型](full-text-search-model.md))。使用 Lucene 語法時，您需要使用此巢狀模型中屬性的完整路徑。

以下是 Gremlin 範例：

```
g.withSideEffect("Neptune#fts.endpoint", "es_endpoint")
 .withSideEffect("Neptune#fts.queryType", "query_string")
 .V()
 .has("*", "Neptune#fts predicates.name.value:\"Jane Austin\" AND entity_type:Book")
```

以下是 SPARQL 範例：

```
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://localhost:9200 (http://localhost:9200/)' .
  neptune-fts:config neptune-fts:queryType 'query_string' .
  neptune-fts:config neptune-fts:query "predicates.\\*foaf\\*name.value:Ronak AND predicates.\\*foaf\\*surname.value:Sh*" .
  neptune-fts:config neptune-fts:field '*' .
  neptune-fts:config neptune-fts:return ?res .
}
```