[gdal-dev] How to read ElasticSearch filters from file?
Even Rouault
even.rouault at spatialys.com
Thu Aug 27 05:43:39 PDT 2015
Le jeudi 27 août 2015 14:26:00, Jukka Rahkonen a écrit :
> Hi,
>
> I was trying the new read capabilities of the ElasticSearch driver
> http://www.gdal.org/drv_elasticsearch.html and I found it extraordinary
> hard to use the json filters from the command line on Windows. It is hard
> also with curl so I saved the filters on disk and read them as -d
> @file.json and that worked well for me.
>
> I tried if I could re-use those proved filters with ogrinfo and ogr2ogr by
> using --optfile but with poor success.
>
> Could it be possible to add a new --config option or perhaps -oo open
> option "ES_QUERY" for reading the json query/filter from a file just like
> curl does with -d @file.json? The same file should work unmodified for
> both software. I think especially newlines which make the filters more
> readable and also most filter examples in the net are formatted with
> newlines. See the examples at
> https://www.elastic.co/guide/en/elasticsearch/guide/current/search-in-depth
> .html
Hi Jukka,
Ah, might be true. The Unix shell allows to paste things like:
$ ogrinfo es: poly2 -where '{ "filter" :
{ "term" :
{
"EAS_ID": 166
}
}
}'
And --optfile indeed will consider stuff on several lines as different options.
What about "ogrinfo ES: the_layer -where @filter.json" ?
Iniitally, I though this could be a hack specific to the ES driver. But there's
the same thing with the mongodb driver. So perhaps an extended behaviour of
the -where options of ogrinfo / ogr2ogr that would do the file reading and
transmit the expanded filter to the driver ? Could be usefull for -sql as well
I guess.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list