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

create_index.js Bad Request #240

Closed
longingchai opened this issue Sep 7, 2017 · 8 comments
Closed

create_index.js Bad Request #240

longingchai opened this issue Sep 7, 2017 · 8 comments

Comments

@longingchai
Copy link

"npm test" in schema all passed , but got "Bad Request" when I run "node scripts/create_index.js", can anyone help me to fix this problem ?

@orangejulius
Copy link
Member

Hey @longingchai,
Thanks for reporting in. Can you share a little more information about your setup to help us figure out what might be wrong?

Some things that would help are:

  • the full output of running node scripts/create_index.js
  • Node.js version (node -v)
  • Elasticsearch info (the full output of curl http://localhost:9200, substituting localhost for the location of your Elasticsearch server if needed, would be excellent)

@jeremy-prater
Copy link

jeremy-prater commented Sep 12, 2017

I also get the same issue, I am using elastic search 5.6.0, which fails. If I use 2.4.0, it works fine. I believe it is because the create_index is using an older version of elasticsearch npm module, which calls HTTP POST instead of HTTP PUT for creating the index.

This pull request removed HTTP POST support for creating indices elastic/elasticsearch#20001

@jeremy-prater
Copy link

I got past the API error by specifying the API version in the pelias_config, however there is another issue now.

{ apiVersion: '5.x',
keepAlive: true,
requestTimeout: '120000',
hosts:
[ { env: 'development',
protocol: 'http',
host: 'localhost',
port: 9200 } ],
log: [ { type: 'stdio', level: [Object] } ] }


create index

[mapper_parsing_exception] Mapping definition for [center_point] has unsupported parameters: [geohash : true] [geohash_precision : 18] [lat_lon : true] [geohash_prefix : true]

{ error:
{ root_cause: [ [Object] ],
type: 'mapper_parsing_exception',
reason: 'Failed to parse mapping [default]: Mapping definition for [center_point] has unsupported parameters: [geohash : true] [geohash_precision : 18] [lat_lon : true] [geohash_prefix : true]',
caused_by:
{ type: 'mapper_parsing_exception',
reason: 'Mapping definition for [center_point] has unsupported parameters: [geohash : true] [geohash_precision : 18] [lat_lon : true] [geohash_prefix : true]' } },
status: 400 }

@jeremy-prater
Copy link

jeremy-prater commented Sep 12, 2017

I made a work around, not sure if it broke everthing else though. I managed to get the index created by commenting out lat_lon, and all 3 geohash elements from centroid.js. I believe they are provided automatically now.

{ apiVersion: '5.x',
keepAlive: true,
requestTimeout: '120000',
hosts:
[ { env: 'development',
protocol: 'http',
host: 'localhost',
port: 9200 } ],
log: [ { type: 'stdio', level: [Object] } ] }


create index

[put mapping] pelias { acknowledged: true,
shards_acknowledged: true,
index: 'pelias' }

https://stackoverflow.com/questions/42385407/mapping-definition-for-location-has-unsupported-parameters-geohash-true

diff --git a/mappings/partial/centroid.js b/mappings/partial/centroid.js                                 
index 172c2bf..2177018 100644                       
--- a/mappings/partial/centroid.js                  
+++ b/mappings/partial/centroid.js                  
@@ -3,12 +3,12 @@ var schema = {                    
   'type': 'geo_point',                             
                                                    
   /* `lat_lon` enabled since both the geo distance and bounding box filters can either be executed using in memory checks, or using the indexed lat lon values */                                                 
-  'lat_lon': true,                                 
+  //'lat_lon': true,                               
                                                    
   /* store geohashes (with prefixes) in order to facilitate the geohash_cell filter */                  
-  'geohash': true,                                 
-  'geohash_prefix': true,                          
-  'geohash_precision': 18                          
+  //'geohash': true,                               
+  //'geohash_prefix': true,                        
+  //'geohash_precision': 18                        
 };                                                 
                                                    
 module.exports = schema;   

@orangejulius
Copy link
Member

Hey @jeremy-prater,
That makes sense. We unfortunately don't yet support Elasticsearch 5. It's not on our immediate roadmap to work on, but we do want to do it eventually and anything we can do to take baby steps in that direction we want to do.

We do have a PR open to achieve Elasticsearch 5 compatibility. Can you take a look at that branch and see how the changes in there compare to the ones you made? Also if you could report on if those ES5 compatible changes work with ES2, that would be a huge help. Ideally we would be able to at least unofficially support ES5, while still working on ES2 soon.

@eldie1984
Copy link

For the POST error you can add the method you want to use to create the index. The line 19 of the file scripts/create_index.js look like this
client.indices.create( {method:'PUT', index: indexName, body: schema }, function( err, res ){

@orangejulius
Copy link
Member

Hey @eldie1984,
That's good to know. Do we have to do that though? I think changing the pelias.json configuration entry for the Elasticsearch version (as @jeremy-prater mentioned above), will take care of that, as the Elasticsearch module will then do the right thing based on that version. But if that's not true let me know, and we'll add it to the list of changes to make.

@jeremy-prater
Copy link

Correct, changing the apiVersion in pelias.json is sufficient to use the correct interface. I've been running importers all night. I'm up to ~140 mil indexes so far! I haven't tried the front end of Pelias yet, I've just been playing around in Kibana

image

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

4 participants