While the language analyzers can be used out of the box without any configuration, most of them do allow you to control aspects of their behavior, specifically:
Imagine, for instance, that users searching for the World Health
Organization'' are instead getting results for
organ health.'' The reason
for this confusion is that both organ'' and
organization'' are stemmed to
the same root word: organ
. Often this isn’t a problem, but in this
particular collection of documents, this leads to confusing results. We would
like to prevent the words organization
and organizations
from being
stemmed.
The default list of stopwords used in English are as follows:
a, an, and, are, as, at, be, but, by, for, if, in, into, is, it, no, not, of, on, or, such, that, the, their, then, there, these, they, this, to, was, will, with
The unusual thing about no
and not
is that they invert the meaning of the
words that follow them. Perhaps we decide that these two words are important
and that we shouldn’t treat them as stopwords.
To customize the behavior of the english
analyzer, we need to
create a custom analyzer that uses the english
analyzer as its base but
adds some configuration:
PUT /my_index
{
"settings": {
"analysis": {
"analyzer": {
"my_english": {
"type": "english",
"stem_exclusion": [ "organization", "organizations" ], (1)
"stopwords": [ (2)
"a", "an", "and", "are", "as", "at", "be", "but", "by", "for",
"if", "in", "into", "is", "it", "of", "on", "or", "such", "that",
"the", "their", "then", "there", "these", "they", "this", "to",
"was", "will", "with"
]
}
}
}
}
}
GET /my_index/_analyze?analyzer=my_english (3)
The World Health Organization does not sell organs.
Prevents organization
and organizations
from being stemmed
Specifies a custom list of stopwords
Emits tokens world
, health
, organization
, does
, not
, sell
, organ
We discuss stemming and stopwords in much more detail in [stemming] and [stopwords], respectively.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。