# Java - finding exact values

**URL:** <https://discuss.elastic.co/t/java-finding-exact-values/51281>\
**Category:** Elasticsearch\
**Created:** [May 30, 2016, 7:16am UTC](https://discuss.elastic.co/t/java-finding-exact-values/51281 "2016-05-30T07:16:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveyx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveyx/32/35298_2.png) [@daveyx](https://discuss.elastic.co/u/daveyx)\
**Post date:** [May 30, 2016, 7:16am UTC](https://discuss.elastic.co/t/java-finding-exact-values/51281/1 "2016-05-30T07:16:23Z")

</div>

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](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();
```

---

<div class="post-metadata">

**Author:** ![daveyx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveyx/32/35298_2.png) [@daveyx](https://discuss.elastic.co/u/daveyx)\
**Post date:** [May 30, 2016, 8:05am UTC](https://discuss.elastic.co/t/java-finding-exact-values/51281/2 "2016-05-30T08:05:14Z")

</div>

got it working:

> <https://stackoverflow.com/questions/23552845/configure-elasticsearch-mapping-with-java-api/23555260#23555260>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:48pm UTC](https://discuss.elastic.co/t/java-finding-exact-values/51281/3 "2017-07-05T22:48:10Z")

</div>


