Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to setup default similarity or more similarities with different name. #8067

Closed
petr-horny-bsshop opened this issue Mar 27, 2024 · 2 comments
Labels
8.x Relates to 8.x client version Area: Generator Category: Bug

Comments

@petr-horny-bsshop
Copy link

It is not possible to create similarity with custom name, eg. "default". The names are hardcoded. For the same reason it is not possible to create two similarities of same type with different settings.

In NEST you can for example create BM25 similarity named "default":

var client = new ElasticClient(nodeUri);

await client.Indices.CreateAsync("my_index2", index =>
    index.Settings(settings =>
        settings.Similarity(similarity =>
            similarity.BM25("default", _ => new BM25Similarity())
        )
    )
);

In Elasticsearch-net client you cannot specify name:

var client = new ElasticsearchClient(nodeUri);

await client.Indices.CreateAsync("my_index1", index =>
    index.Settings(settings =>
        settings.Similarity(similarity =>
            similarity.Bm25(_ => { })
        )
    )
);

The NEST version creates this:
image

The Elasticsearch-net creates this:
image

You cannot create "default" similarity.
You cannot create more similarites of same type with different name and settings.

@flobernd flobernd added the 8.x Relates to 8.x client version label Mar 27, 2024
@flobernd
Copy link
Member

Hi @petr-horny-bsshop, thanks for reporting!

Version 8.13.0 will be released on April 3rd. This version is the first one based on a completely revisited code generator. For the cost of some breaking changes, a lot of the previously unsupported features and endpoints will be available.

I just tested your case in the 8.13 code-base and I can confirm, that the following will be supported again:

await client.Indices.CreateAsync("my_index1", index =>
	index.Settings(settings => settings
		.Similarity(similarities => similarities
			.Bm25("sim1", _ => { })
			.Bm25("sim2", _ => { })
		)
	)
);

and creates the correct request:

{"settings":{"similarity":{"sim1":{"type":"BM25"},"sim2":{"type":"BM25"}}}}

@petr-horny-bsshop
Copy link
Author

Hi @flobernd, that's great news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Area: Generator Category: Bug
Projects
None yet
Development

No branches or pull requests

2 participants