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

error [_id] is defined twice #158

Open
traboukos opened this issue Dec 7, 2016 · 14 comments
Open

error [_id] is defined twice #158

traboukos opened this issue Dec 7, 2016 · 14 comments

Comments

@traboukos
Copy link

Hello I have been struggling all day with this error while trying to run ./manage.py search_index --create

I am using the following packages
elasticsearch server Version: 5.0.2, Build: f6b4951/2016-11-24T10:07:18.101Z, JVM: 1.8.0_65
elasticsearch 5.0.1
elasticsearch-dsl 5.0.0
bungiesearch 1.3.1 # tried this with master also same error

This is my model

class ChatIndex(ModelIndex):
    """Search index for Chat model"""   

    class Meta(object):
        """Meta data"""
        model = Chat
        default = True

and those are the mappings generated for the model

{'properties': {
  '_id': {'type': 'integer'},
  'created_at': {'type': 'date'},
  u'id': {'type': 'integer'},
  'text': {'analyzer': 'snowball', 'type': 'string'},
  'timestamp': {'type': 'date'},
  'updated_at': {'type': 'date'}}
}

following is the error displayed in the console while running the command

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/bungiesearch/management/commands/search_index.py", line 138, in handle
    es.indices.create(index=index, body={'mappings': mapping, 'settings': {'analysis': analysis}})
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 71, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 107, in create
    params=params, body=body)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/elasticsearch/transport.py", line 327, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 124, in perform_request
    self._raise_error(response.status, raw_data)
  File "/Users/dstefanidis/.virtualenvs/bingo/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 122, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, u'mapper_parsing_exception', u'Failed to parse mapping [Chat]: Field [_id] is defined twice in [Chat]')
@ChristopherRabotin
Copy link
Owner

ChristopherRabotin commented Dec 7, 2016 via email

@traboukos
Copy link
Author

@ChristopherRabotin this is a new index

@ChristopherRabotin
Copy link
Owner

Have you solved the issue? Sorry for not getting back to you earlier.

@traboukos
Copy link
Author

Hey thanks for the answer. Unfortunately after being plagued by this error plus various other errors I had to abandon this library and chose to use dsl-py directly. This has sped up my progress and gave me more control over the queries which is something I needed.

I am pretty sure I could do all the things I need with bungiesearch also but the documentation needs some work. For example there is not a single reference to the word aggregation neither in the docs nor the submitted issues. Faceting and aggregating data is one of the main reason I always use a search engine. I did not manage to find any info or example about how to do this. Same for multi valued fields like arrays. I could not easily find info about how to index them.

@traboukos
Copy link
Author

@ChristopherRabotin I would like to revisit bungiesearch now that I made some progress using dsl-py directly. Could you answer my questions above ? Is it possible to use Keyword fields and perform aggregations ? Thanks in advance.

@ChristopherRabotin
Copy link
Owner

ChristopherRabotin commented Dec 20, 2016 via email

@umbrae
Copy link

umbrae commented Jan 30, 2017

I ran into this same issue FWIW. Some pdbing brought me to my mapping that looked like this:

{
    "mappings": {
        "Profile": {
            "properties": {
                "id": {
                    "type": "integer"
                },
                // ...other fields here...
                "_id": {
                    "type": "integer"
                }
            }
        }
    },
    "settings": {
        "analysis": {}
    }
}

I only just started using ES within the last day, so I have no idea if that's accurate, but removing _id from the create looked to work well, and the reindex seemed to genuinely reindex as expected.

Possibly ES somewhere is trying to be smart, and if it sees both an id key and an _id key is considering them a conflict?

@ChristopherRabotin
Copy link
Owner

Yeah, that's possible I guess. What version of ES ae you running?

@umbrae
Copy link

umbrae commented Jan 30, 2017

2.4.4

@ChristopherRabotin
Copy link
Owner

Interesting. Okay. Thanks for the info. I don't really have a solution yet, and don't know when I will. I don't use bungiesearch anymore because I don't have any project that uses elasticsearch... But if I get around to it, I'll attempt to fix this. Sorry.

@umbrae
Copy link

umbrae commented Jan 30, 2017

No problem, honestly I switched away from it and started using elasticsearch-dsl which seems to be going well. Less creature comforts than bungiesearch but I can deal. Thanks for putting this out there!

@umbrae
Copy link

umbrae commented Jan 30, 2017

(I will say it might be worthwhile to update your readme and state it's not actively being maintained, I bet you'll feel less stress from people posting issues if you do that as well.)

@ChristopherRabotin
Copy link
Owner

Yes, that's a good idea. I will do that.

(I won't hide that I would have loved seeing bungiesearch used at reddit... Haha, next time! If you guys need some go development, especially astrodynamic simulations, let me know!!)

@umbrae
Copy link

umbrae commented Jan 30, 2017

Haha well I will say that this was for a side project, but we are definitely hiring: https://boards.greenhouse.io/reddit

We have some go but it's mostly our statsd clone and some ad serving stuff.

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