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

add index mapping #51

Open
dijadev opened this issue Nov 30, 2016 · 5 comments
Open

add index mapping #51

dijadev opened this issue Nov 30, 2016 · 5 comments

Comments

@dijadev
Copy link

dijadev commented Nov 30, 2016

Hi!
How could I define a mapping for each field?
I want all my index fields to be indexed with mapping "not_analyzed" so i can get exacte values in search results.

Thank you,

@jayzeng
Copy link
Owner

jayzeng commented Jan 3, 2017

@dijadev this is a elasticsearch question, I would suggest you to follow https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

@jayzeng jayzeng closed this as completed Jan 3, 2017
@hieu-n
Copy link

hieu-n commented Jan 6, 2017

I found this issue by Google. I think @dijadev was aware of insert/update Elasticsearch mappings by using the REST API. I guess what @dijadev meant is a way to define the mapping (or the template) from ScrapyElasticsearch pipeline settings. For an example:

# in settings.py
ELASTICSEARCH_INDEX_MAPPING = {
# some mapping settings here
}
ELASTICSEARCH_TEMPLATE = {
# some template settings here
}

In from_crawler methods, we could add some code to upload this template/mapping to Elasticsearch server (by using put_template and put_mapping methods from the official elasticsearch python library: https://elasticsearch-py.readthedocs.io/en/master/api.html).

I got this idea from Logstash (I am sure you guys know what it is). It also has the configuration to define the template (template, template_name, template_overwrite, ...): https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template

I hope @jayzeng may consider this as a feature request.

@jayzeng jayzeng reopened this Jan 6, 2017
@jayzeng
Copy link
Owner

jayzeng commented Jan 6, 2017

@hieu-n thanks for elaborating the issue, template in logstash accepts a mapping json. Is that what you are looking for? I can implement the feature by providing similar settings (template, which is a mapping file, template_name and template_overwrite)

@hieu-n
Copy link

hieu-n commented Jan 6, 2017

@jayzeng I think putting the mapping in a separate json file as logstash does is a good idea, because the mapping could be lengthy and complex. However, it is up to you to decide.

@dijadev
Copy link
Author

dijadev commented Jan 6, 2017

@hieu-n Yah it's exactly what I was looking for, but finally I defined the mapping in elasticsearch directly as described in elasticseach doc..
Thanks everyone !

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

No branches or pull requests

3 participants