index_options
编辑index_options
编辑index_options
参数控制将哪些信息添加到倒排索引中,以用于搜索和高亮显示。只有基于词项的字段类型,如 text
和 keyword
支持此配置。
该参数接受以下值之一。每个值都会检索之前列出的值的信息。例如,freqs
包含 docs
;positions
包含 freqs
和 docs
。
resp = client.indices.create( index="my-index-000001", mappings={ "properties": { "text": { "type": "text", "index_options": "offsets" } } }, ) print(resp) resp1 = client.index( index="my-index-000001", id="1", document={ "text": "Quick brown fox" }, ) print(resp1) resp2 = client.search( index="my-index-000001", query={ "match": { "text": "brown fox" } }, highlight={ "fields": { "text": {} } }, ) print(resp2)
response = client.indices.create( index: 'my-index-000001', body: { mappings: { properties: { text: { type: 'text', index_options: 'offsets' } } } } ) puts response response = client.index( index: 'my-index-000001', id: 1, body: { text: 'Quick brown fox' } ) puts response response = client.search( index: 'my-index-000001', body: { query: { match: { text: 'brown fox' } }, highlight: { fields: { text: {} } } } ) puts response
const response = await client.indices.create({ index: "my-index-000001", mappings: { properties: { text: { type: "text", index_options: "offsets", }, }, }, }); console.log(response); const response1 = await client.index({ index: "my-index-000001", id: 1, document: { text: "Quick brown fox", }, }); console.log(response1); const response2 = await client.search({ index: "my-index-000001", query: { match: { text: "brown fox", }, }, highlight: { fields: { text: {}, }, }, }); console.log(response2);