ElasticSearch:有没有办法从文本字段中获取令牌或引理列表

时间:2017-06-25 09:11:09

标签: elasticsearch

我有一个带有analyzer映射字段的索引。根据文档,analyzer将有助于使用词干标记进行搜索(也可能使用引理)。

但我想知道,如果我想要由弹性搜索分析仪生成的令牌,引理列表,这可能吗?

1 个答案:

答案 0 :(得分:0)

我不确定这是你在找什么。但你可以这样做:

GET YOU_INDEX_NAME_HERE/_analyze

{
    "analyzer": "ANALYZER_NAME_HERE",
    "text": "This Is a test text for analyze"
}

响应将是令牌列表。

例如,对于此查询:

{
    "analyzer": "standard",
    "text": "This Is a test"
}

你会得到答复:

{
    "tokens": [
        {
            "token": "this",
            "start_offset": 0,
            "end_offset": 4,
            "type": "<ALPHANUM>",
            "position": 0
        },
        {
            "token": "is",
            "start_offset": 5,
            "end_offset": 7,
            "type": "<ALPHANUM>",
            "position": 1
        },
        {
            "token": "a",
            "start_offset": 8,
            "end_offset": 9,
            "type": "<ALPHANUM>",
            "position": 2
        },
        {
            "token": "test",
            "start_offset": 10,
            "end_offset": 14,
            "type": "<ALPHANUM>",
            "position": 3
        }
    ]
}

documentation

中的更多信息