0

I find the way to create Nest elasticSearch client which contains default index with my custom analyzer. I know that I can create the client with default index and type name. I looks like this:

ElasticClient client = new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200"))
                                                                      .DefaultIndex("my_index_name")
                                                                      .DefaultTypeNameInferrer(type => "my_type_name"));

But I don't know how to assign custom analyzer to default index at the same time. Is it possible?

1 Answer 1

1

Setting

.DefaultIndex("my_index_name")

only tells the client the name of the index to use if no index has been specified on the request, and no index has been specified for a given POCO type T. It's important to note that it doesn't create an index.

Analyzers can be added when creating an index

client.CreateIndex("index-name", c => c
    .Settings(s => s
        .Analysis(a => a
            // add new Analyzers, Tokenizers, CharFilters, TokenFilters
        )
    )
);

or by updating an existing index

client.UpdateIndexSettings("index-name", u => u
    .IndexSettings(i => i
        .Analysis(a => a
            // add new Analyzers, Tokenizers, CharFilters, TokenFilters
        )
    )
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.