Hi,
i want mark a mapping with "not_analyzed" in java like described here:
https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_query_with_text
After the code below, i index two products, refresh the index and run a
termQuery("productUrl", "man-prod2")
But i still get both documents, so i think in my code below is something wrong to set the mapping as "not_analyzed"
Any suggestions?
Kind regards
David
final Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
client.admin().indices().create(new CreateIndexRequest("myindex")).actionGet();
final XContentBuilder xcb = XContentFactory.jsonBuilder().prettyPrint()
.startObject()
.startObject("products")
.startObject("properties")
.startObject("productUrl").field("type", "string").field("index", "not_analyzed").endObject()
.endObject()
.endObject()
.endObject();
final IndexResponse response = client.prepareIndex("myindex", "products")
.setSource(xcb.string())
.execute()
.actionGet();