1

I want the B field stored in Elasticsearch but never indexing. When I search for "Nash" I do not want to search within the B field. So the B field is not indexed in elastic.

    [ElasticsearchType(Name = "ES6")]
    public class ES6
    {
        public string A { get; set; }

        public string B { get; set; }
    }

    elasticClient.IndexDocument(new ES6 { A = "John", B = "Nash" });

    elasticClient.IndexDocument(new ES6 { A = "Nash", B = "John" });

1 Answer 1

1

If you want to have a field not be indexed you can use the NEST Attributes to show that the field should not be indexed.

https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/attribute-mapping.html

In your example, it would probably be something like this:

[ElasticsearchType(Name = "ES6")]
public class ES6
{
    [Text]
    public string A { get; set; }

    [Keyword(Index = false)]
    public string B { get; set; }
}

Setting it to keyword will make sure it is not analyzed and setting Index = false will tell Elastic not to index it.

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.