question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Analyzer is not being applied to fields?

See original GitHub issue
contracts = Index('contracts')
my_analyzer = analyzer('simple')

contracts.analyzer(my_analyzer)


@contracts.doc_type
class ContractDocument(DocType):
    client = fields.StringField(attr='client_name')

    class Meta:
        model = Contract

        fields = [
            'id',
            'name'
        ]

I am trying to apply simple analyzer on fields. But when I call termvectors after running search_index, I see that standard analyzer is applied on fields.

How can I apply simple analyzer to all fields?

I have tons of fields, I don’t want to declare them by hand. Only solution is to create an ES Field for each model field? How can I declare analyzer for fields in Meta.fields or how can I modify my class to do this?

You can discard the Django related parts.

I guess this kind of analyzer settings does not do this:

PUT /contracts
{
  "mappings": {
    "contract_document":{
      "properties": {
        "name":{
          "type":"text",
          "analyzer": "simple"
        }
      }
    }
  }
}

Right?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
honzakralcommented, Oct 27, 2017

You can define an analyzer for a field by passing it as a parameter to the field class: name = Text(analyzer='simple')

unfortunately I am not familiar with the API that you are using, but just passing a name of a built-in analyzer or an Analyzer instance should work.

1reaction
honzakralcommented, Oct 27, 2017

If you don’t create the index explicitly an empty index with default mappings (== using standard analyzer) will be created for you. That is why you have to create the index explicitly before pushing any documents in. See (0) for more details.

0 - http://elasticsearch-dsl.readthedocs.io/en/latest/persistence.html#document-life-cycle

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating Documents in Elasticsearch is not Applying the ...
When creating documents normally with data in Field the analyzer is working correctly. Field has the data in lowercase and Field.raw has the ......
Read more >
Hash tag field analyzer not being applied - Elasticsearch
Hello! I have configured an analyzer in my YML to exclude all words that do not start with either # or @ to...
Read more >
Running Your Analyzer | Apache Solr Reference Guide 6.6
Once you've defined a field type in your Schema, and specified the analysis steps that you want applied to it, you should test...
Read more >
Analyzer and search_analyzer on field
A detailed guide on how to resolve errors related to "analyzer and search_analyzer on field"
Read more >
Add language analyzers to string fields - Azure
How to specify a language analyzer · In the field definition, make sure the field is attributed as "searchable" and is of type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found