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

Default Elasticsearch index mappings. #27

Merged
merged 3 commits into from
Aug 30, 2022

Conversation

j-bennet
Copy link
Contributor

@j-bennet j-bennet commented Aug 27, 2022

Closes https://github.com/elastic/enterprise-search-team/issues/2610

Adds index mappings for connectors and crawler indices to support relevance tuning in App Search (pretty much ports elastic/connectors-ruby#131 to python).

The added index mappings + settings are not used anywhere right now. For the next step, I would need some guidance. Should these settings be used in connectors-python library, if so, where? Should they be used by a user that uses our library? Do we want another action in the CLI to initialize an index with these mappings / settings? Or perhaps just add documentation about these settings into README?

Usage:

In [1]: from elasticsearch import Elasticsearch

In [3]: client = Elasticsearch('http://localhost:9200', basic_auth=('elastic','changeme'))

In [4]: from templates.elasticsearch.index.mappings import IndexMappings

In [5]: from templates.elasticsearch.index.settings import IndexSettings

In [7]: mappings = IndexMappings.default_text_fields_mappings(is_connectors_index=True)

In [9]: settings = IndexSettings(language_code='fr', analysis_icu=False).to_hash()

In [10]: client.indices.create(index='search-my-index', settings=settings, mappings=mappings)
Out[10]: ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'my-test-connectors'})

TODO:

  • finish unit tests for utils.elasticsearch.index.settings.IndexSettings

Checklists

Pre-Review Checklist

  • Covered the changes with automated tests
  • Tested the changes locally

Related Pull Requests

elastic/connectors-ruby#131

Adds index mappings for connectors and crawler indices to support relevance tuning in App Search.
See https://github.com/elastic/enterprise-search-team/issues/2610.
Essentially ports elastic/connectors-ruby#131 to python.
@j-bennet j-bennet marked this pull request as draft August 27, 2022 01:19
@seanstory
Copy link
Member

😲 wow, that was fast. Awesome!

Add more tests for IndexSettings.
Is Index Settings a good name? It's called TextAnalysisSettings in connectors-ruby.
@j-bennet j-bennet marked this pull request as ready for review August 29, 2022 21:30
Copy link
Member

@seanstory seanstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MVP

@j-bennet j-bennet merged commit a0f8091 into main Aug 30, 2022
@j-bennet j-bennet deleted the j-bennet/default-es-index-mappings branch August 30, 2022 16:04
@tarekziade
Copy link
Contributor

Thanks for this work @j-bennet

I think what we could do is plug your work into byoc.BYOConnector.sync when it calls prepare_index

I will add a new issue to list the possible steps to do this

@tarekziade
Copy link
Contributor

#28

@j-bennet j-bennet mentioned this pull request Sep 3, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants