Change/update of the datatype of latitude and longitude from double to geo_points

2015-03-24 Thread nidhi chawhan
Hi Team,

I wanted to update the datatype of latitude and longitude fields from 
double to geo_points .

Index name  :- visit.hippo_en
Type :- visit:PlaceDocument

PUT /visit.hippo_en/visit:PlaceDocument/_mapping
{ 
"location": {
  "properties" :{
"coordinates": {
"properties":{
  "coordinates": {
 "properties":{ 
"latitude": {
"type": "geo_point"
   
 },
 "longitude": {
"type": "geo_point"
   
 }
 }
  }
 
  }
}
  }
   }
}

then getting below error 


{
   "error": "MapperParsingException[Root type mapping not empty after 
parsing! Remaining fields:   [location : 
{properties={coordinates={properties={coordinates={properties={latitude={type=geo_point},
 
longitude={type=geo_point}}}]]",
   "status": 400
}

when trying to update through java API
below is the code

CreateIndex createIndex = new CreateIndex.Builder(visitHippoIndexName + 
UNDERSCORE + lang).build();
jestClient.execute(createIndex);

String geoPointMapping = "\n" +
"\"location\": {\n" +
"  \"properties\" :{\n" +
"\"coordinates\": {\n" +
"\"properties\":{\n" +
"  \"coordinates\": {\n" +
" \"properties\":{ \n" +
"\"latitude\": {\n" +
"\"type\": \"geo_point\"\n" +
"   \n" +
" },\n" +
" \"longitude\": {\n" +
"\"type\": \"geo_point\"\n" +
"   \n" +
" }\n" +
" }\n" +
"  }\n" +
" \n" +
"  }\n" +
"}\n" +
"  }\n" +
"   }";

if(nodeType.equals("visit:PlaceDocument")){
PutMapping keyMapping = new PutMapping.Builder(visitHippoIndexName + 
UNDERSCORE + lang, nodeType, geoPointMapping).build();
jestClient.execute(keyMapping);
}


Index index = new Index.Builder(source).index(visitHippoIndexName + 
UNDERSCORE + lang).type(nodeType).id(handleNode.getIdentifier()).build();
jestClient.execute(index);

It gives me below exception

2015-03-24 10:27:13,787][DEBUG][action.admin.indices.mapping.put] 
[Carnivore] failed to put mappings on indices [[visit.hi
po_en]], type [visit:PlaceDocument]
rg.elasticsearch.index.mapper.MapperParsingException: malformed mapping no 
root object found
   at 
org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:338)
   at 
org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:183)
   at 
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:444)
   at 
org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:505)
   at 
org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)
   at 
org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(Prio
itizedEsThreadPoolExecutor.java:153)
   at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:745)

i am giving the root object which is location in this case.
But still error.

Please advise how to update the double object to geopoints?


Thanks,
Nidhi



-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


JsonGenerationException for Boosting query

2015-03-18 Thread nidhi chawhan
Hi Team,
I am using jest client to execute the execute the query.


Here is the ES query


GET visit.hippo_en/visit:PlaceDocument/_search
{
  "query": {
"bool": {
  "should": [
{
  "match": {
"title.value": {
  "query": "automium bar",
  "fuzziness":"AUTO",
  "prefix_length":3,
  "analyzer":"visit_hippo_analyser",
  "boost": 5
}
  }
},
{
  "match": { 
"_all": {
  "query": "automium bar",
  "fuzziness":"AUTO",
  "prefix_length":3,
  "analyzer":"visit_hippo_analyser"
  }
}
}
  ],
  "minimum_should_match": 1
}
  }
}

Below is my json builder 


XContentBuilder contentBuilder = XContentFactory.jsonBuilder()
.startObject()
.startObject("query")
 .startObject("bool").field("minimum_should_match",1)
.startObject("should").field(
XContentFactory.jsonBuilder().startObject("match")
  .startObject("title.value")
   .field("query", text)
   .field("fuzziness","AUTO")
   .field("prefix_length", 3)
   .field("analyzer","visit_hippo_analyser")
   .field("boost",5)
  .endObject()
.endObject().toString()).field(
XContentFactory.jsonBuilder().startObject("match")
.startObject("_all")
.field("query", text)
.field("fuzziness","AUTO")
.field("prefix_length", 3)
.field("analyzer","visit_hippo_analyser")
.endObject()
.endObject().toString())
.startObject()
 .endObject()
.endObject()
.endObject();

Search search = new Search.Builder(contentBuilder.string())
.addIndex(visitHippoIndexName+"_"+lang).addType("visit:PlaceDocument")
.build();
try
{
io.searchbox.core.SearchResult result = jestClient.execute(search);
if (result.isSucceeded())
{
List> hits = 
result.getHits(SearchResultJson.class);
for (io.searchbox.core.SearchResult.Hit hit : hits)
{
results.add(SearchResult.fromSearchResultJson(hit.source));
System.out.println(hit.source.getTitle().getSource());
}
}
} catch (Exception e)
{
logger.error("Exception occurred for while executing Search query", 
e.getMessage());
throw new Exception("System problem with do searching based on text");
}
return results;



But i am getting the exception 
org.elasticsearch.common.jackson.JsonGenerationException: Can not write a 
field name, expecting a value

*i am not to find the how to write having "should" syntax in java *

Please help me to provide the to build the JSON so that i can fire it 
through jest client.Response will be appreciated!!!

Thanks

Nidhi

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3ba6a71e-70c1-4b02-b479-17a6617a60dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.