同步操作将从 Hutool/elasticsearch-definitive-guide-cn 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
About 5% of all queries are phrase queries (see [phrase-matching]), but they often account for the majority of slow queries. Phrase queries can perform poorly, especially if the phrase includes very common words — a phrase like ``To be or not to be'' could be considered pathological. The reason for this has to do with the amount of data that is necessary to support proximity matching.
In [pros-cons-stopwords] we said that removing stopwords saves only a small amount of space in the inverted index. That was only partially true. A typical index may contain, amongst other data, some or all of:
A sorted list of all terms that appear in the documents in the index, and a count of how many documents contain each term.
A list of which documents contain each term.
How often each term appears in each document.
The position of each term within each document, for phrase and proximity queries.
The start and end character offsets of each term in each document, for snippet highlighting. Disabled by default.
A factor used to normalize fields of different lengths, to give shorter fields more weight.
Removing stopwords from the index may save a small amount of space in the terms dictionary and the postings list, but positions and offsets are another matter. Positions and offsets data can easily double, triple, or quadruple index size.
Positions are enabled on analyzed
string fields by default, so that phrase
queries will work out of the box. The more often that a term appears, the more
space that is needed to store its position data. Very common words, by
definition, appear very commonly and their positions data can run to megabytes
or gigabytes on large corpuses.
Running a phrase query on a high frequency word like the
might result in
gigabytes of data being read from disk. That data will be stored in the kernel
file system cache to speed up later access, which seems like a good thing, but
it might cause other data to be evicted from the cache which will slow down
subsequent queries.
This is clearly a problem that needs solving.
The first question you should ask yourself is: ``Do you need phrase or proximity queries?''
Often, the answer is no. For many use cases, such as logging, you need to
know whether a term appears in a document — information which is provided
by the postings list — but not where it appears. Or perhaps you need to use
phrase queries on one or two fields, but you can disable positions data on all
of the other analyzed string
fields.
The index_options
parameter allows you to control what information is stored
in the index for each field. Valid values are:
docs
Only store which documents contain which terms. This is the default for
not_analyzed
string fields.
freqs
Store docs
information, plus how often each term appears in each
document. Term frequencies are needed for a complete TF/IDF
relevance calculations, but they are not required if you just need to know
whether a document contains a particular term or not.
positions
Store docs
and freqs
, plus the position of each term in each document.
This is the default for analyzed
string fields, but can be disabled if
phrase/proximity matching is not needed.
offsets
Store docs
, freqs
, positions
and the start and end character offsets
of each term in the original string. This information is used by the
{ref}search-request-highlighting.html#postings-highlighter[postings
highlighter]
but is disabled by default.
You can set index_options
on fields added at index creation time, or when
adding new fields using the put-mapping
API. This setting can’t be changed
on existing fields:
PUT /my_index
{
"mappings": {
"my_type": {
"properties": {
"title": { (1)
"type": "string"
},
"content": { (2)
"type": "string",
"index_options": "freqs"
}
}
}
}
The title
field uses the default setting of positions
, so
it is suitable for phrase/proximity queries.
The content
field has positions disabled and so cannot be used
for phrase/proximity queries.
Removing stopwords is one way of reducing the size of the positions data quite
dramatically. An index with stopwords removed can still be used for phrase
queries because the original positions of the remaining terms is maintained,
as we saw in [maintaining-positions]. But of course, excluding terms from
the index reduces searchability. We wouldn’t be able to differentiate between
the two phrases Man in the moon'' and
Man on the moon''.
Fortunately, there is a way to have our cake and eat it: the
common_grams
token filter.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。