Hello everyone,
I'm new to ElasticSearch and I need to migrate an application that is
indexing documents with Lucene to ES.
I set up the environment and run few tests.
Coming from Lucene, I have already defined all my index schema (read
documents) and I want to maintain exactly the same indexing approach.
This is the Lucene document:
public static Document getDocument(ResultSet rs) throws SQLException {
Document doc = new Document();
String postcode = rs.getString("POSTCODE");
doc.add(new Field("postcode", postcode,
Field.Store.YES,Field.Index.ANALYZED));
doc.add(new Field("longitude",
Util.encodeLongitudeForIndex(rs.getDouble("LONGITUDE")), Field.Store.YES,
Field.Index.NOT_ANALYZED));
doc.add(new Field("latitude",
Util.encodeLatitudeForIndex(rs.getDouble("LATITUDE")), Field.Store.YES,
Field.Index.NOT_ANALYZED));
return doc;
}
I have some problem understanding how to map this in ES and the meaning of
the syntax to create a schema template.
I created a template like this:
curl -XPUT localhost:9200/_template/*postcode *-d '
{
"template" : "postcode",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"postcode" : {
"_source" : { "enabled" : false },
"properties" : {
"postcode" : { "type" : "string", "index" : "analyzed",
"store" : "yes" },
"longitude" : { "type" : "string", "index" : "not_analyzed", "store" :
"yes" },
"latitude" : { "type" : "string", "index" : "not_analyzed", "store" : "yes"
}
}
}
}
}
Postcode is the type of the document in Lucene.
Now it looks like I've more objects with the same postcode name in ES:
- I need to use postcode in the url so that ES knows what I am talking
about. This should identify the name of the template. - I need to inform ES that I want to map calls to postcode to this
template - When I declare the mapping again it looks like I've to provide an id
Am I doing it right?
When I index a document is there a way to look at the indexed document in a
way similar to Luke for Lucene?
Thank you for your help,
Tullio
--