We use elasticsearch with couchdb, with the couchdb-river installed.
Now everything works fine, but now I want to be able to sort the results
we get from elasticsearch.
The first problem is that the date field is not a valid date, because
the format is something like this from the database:
2012-12-27T18:58:22Z
And there was a mapping to make it treat like a string. But now I would
need to sort on it, so I should probably change the mapping.
But I have another question about that, should I create a new index
with that mapping or use the PUT Mapping API? What's the difference
between the two possibilities?
The second problem is that I want to sort on things that require some
computation.
For example in the index I have the field:
{'ideas': ['first', 'second', 'third']}
And I need to be able to sort on the length of that list.
How can I do it?
I don't find a scripting way to do it, or a possible core type.
Is the only way to keep track of the number of ideas (and add the field)
in couchdb maybe?
There is no difference between creating an index with a mapping and putting
mapping after you create an index.
You can use script to sort based on the number of ideas using Script Based
Sorting http://www.elasticsearch.org/guide/reference/api/search/sort.html.
However, keeping the count in your application and indexing it as a
separate field might be a much better idea from the performance
perspective.
On Friday, January 11, 2013 5:23:25 AM UTC-5, andrea crotti wrote:
We use elasticsearch with couchdb, with the couchdb-river installed.
Now everything works fine, but now I want to be able to sort the results
we get from elasticsearch.
The first problem is that the date field is not a valid date, because
the format is something like this from the database:
2012-12-27T18:58:22Z
And there was a mapping to make it treat like a string. But now I would
need to sort on it, so I should probably change the mapping.
But I have another question about that, should I create a new index
with that mapping or use the PUT Mapping API? What's the difference
between the two possibilities?
The second problem is that I want to sort on things that require some
computation.
For example in the index I have the field:
{'ideas': ['first', 'second', 'third']}
And I need to be able to sort on the length of that list.
How can I do it?
I don't find a scripting way to do it, or a possible core type.
Is the only way to keep track of the number of ideas (and add the field)
in couchdb maybe?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.