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

Tried updating ES in hook, internal server error #1

Open
jonlachlan opened this issue Apr 21, 2016 · 1 comment
Open

Tried updating ES in hook, internal server error #1

jonlachlan opened this issue Apr 21, 2016 · 1 comment

Comments

@jonlachlan
Copy link

Hi there, I'm working on integrating elasticsearch using this library and the example (https://github.com/Meteor-NY/devshop-elasticsearch). I have a hook that looks like this:

VolunteerProfiles.after.insert((userId, doc) => {
  console.log("[VolunteerProfiles.insert.hook]", doc)
  ES.insert(doc, {fieldsToInclude: FIELDS_TO_INCLUDE});

  console.log("[VolunteerProfiles.insert.hook] ...Adding record to ElasticSearch");
});

However when I insert a new doc, e.g. VolunteerProfiles.insert({interests: "Bike jumping, skydiving, political research, Javascript programming"}) I have the following errors in Meteor:

[VolunteerProfiles.insert.hook] { interests: 'Bike jumping, skydiving, political research, Javascript programming', _id: 'DaFmuaNKFqtEzrnKy' }
Exception while invoking method '/volunteer-profiles/insert' Error: [mapper_parsing_exception] failed to parse

And here's what it says in the ElasticSearch log:

[DEBUG][action.index             ] [Clea] failed to execute [index {[volunteers][profile][DaFmuaNKFqtEzrnKy], source[{"interests":"Bike jumping, skydiving, political research, Javascript programming","_id":"DaFmuaNKFqtEzrnKy"}]}] on [[volunteers][1]]
[...]
Caused by: java.lang.IllegalStateException: Mixing up field types: class org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType != class org.elasticsearch.index.mapper.internal.IdFieldMapper$IdFieldType on field _id

Unfortunately I'm a bit stumped by this. It looks like it has to do with the _id mapping and the dynamic type detection of Elastic.

@Olabayo
Copy link

Olabayo commented Aug 16, 2016

Hi was able to resolve this by manually modifying the packages script to remove the doc._id field, where you have this

alanning_elasticsearch.js file in package folder
Before:

// create a document in Elastic Search
self.EsClient.index({
index: config.index,
type: config.type,
id: doc._id,
body: doc
});

After:

doc.listing_id = doc._id.toString();
delete doc._id;

// create a document in Elastic Search
self.EsClient.index({
  index: config.index,
  type: config.type,
  id: doc.listing_id,
  body: doc
}); 

Just troubleshooting so the proper thing will be to modify the package so that in insert or update into elastic search, it renames the field _id into another field when saving the body (Elasticsearch throws this error because it uses a field called _id internally as well)

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

2 participants