如何在Nest for Elasticsearch中添加完整的词组标记器? [英] how to add a full phrase tokenizer in Nest for Elasticsearch?

查看:148
本文介绍了如何在Nest for Elasticsearch中添加完整的词组标记器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用小平面创建搜索时,我希望小平面结果在整个短语上,而不是单个单词。我希望它不要区分大小写,因为'not_analyzed'会做。

when i create a search using facets, i want the facet results to be on the whole phrase, not the individual word. and i want it NOT to be case sensitive - as 'not_analyzed' would do.

例如,如果我有一个音乐json对象,并希望组织基于面的结果在类型上,我想看到每个流派是整个流派术语(节奏和蓝调),而不是节奏和蓝调的一个方面,我想能够搜索节奏和蓝调,并且它匹配节奏和蓝调(通知情况)。

for example, if i have a music json object and want to organize the facet results based on genre, i want to see each genre as the whole genre term (rhythm and blues) and not one facet for 'rhythm' and one for 'blues', and i want to be able to search on 'rhythm and blues' and have it match 'Rhythm and Blues' (notice case).

似乎弹性搜索文档建议使用分类器和小写过滤器的自定义分析器。

it seems the elasticsearch documentation suggests using a custom analyzer of a tokenizer and lowercase filter.

这里是弹性搜索的建议我提到:(中页)
http://www.elasticsearch.org/blog/starts-with-phrase-matching/

here's the suggestion from elasticsearch i mentioned: (mid-page) http://www.elasticsearch.org/blog/starts-with-phrase-matching/

我想能够说(在伪代码中的POCO中):

I want to be able to say something like (in my POCO in pseudo code):

[ElasticProperty(Analyzer = "tokenizer, lowercase"]
public string Genre {get;set;}


推荐答案

使用多字段键入您的映射,这样做将允许您以两种方式对类型字段进行索引(使用标准或小写分析器)进行搜索,而不是分析分析。

Use the multi field type in your mapping. Doing so will allow you to index the Genre field in two ways- analyzed (using the standard or lowercase analyzer) for conducting searches, and not_analyzed for faceting.

对于像这样的更高级的映射,NEST中基于属性的映射不会被剪切,你必须使用th流利的API,例如:

For more advanced mappings like this, the attribute based mapping in NEST won't cut it. You'll have to use the fluent API, for example:

client.CreatIndex("songs", c => c
.AddMapping<Song>(m => m
    .MapFromAttributes()
    .Properties(props => props
        .MultiField(mf => mf
            .Name(s => s.Genre)
            .Fields(f => f
                .String(s => s.Name(o => o.Genre).Analyzer("standard"))
                .String(s => s.Name(o => o.Genre.Suffix("raw")).Index(FieldIndexOption.not_analyzed)))))));

希望这有帮助!

这篇关于如何在Nest for Elasticsearch中添加完整的词组标记器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆