Should not analyze the data while indexing and searching

(Sanjay Reddy) #1

I have an issue regarding Elasticsearch Indexing and searching.
I'm trying to index data to elasticsearch using java. After indexing I have observed that it is taking "Kenneth Cole" as "Kenneth" and "Cole".

This is happening while searching the data from elasticsearch also. If I search for "Kenneth Cole", it is searching for "Kenneth" OR "Cole". I'm using the following code.

public class elastic {

	public static void main(String[] args) throws IOException {
		Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

		BulkRequestBuilder bulkRequest = client.prepareBulk();
		bulkRequest.add(client.prepareIndex("twitter", "tweet", "1")
		                        .field("user", "kimchy")
		                        .field("postDate", new Date())
		                        .field("message", "trying out Elasticsearch")
		bulkRequest.add(client.prepareIndex("twitter", "tweet", "3")
		                        .field("user", "kimchy")
		                        .field("postDate", new Date())
		                        .field("message", "another post")
		                  )  );	
		BulkResponse bulkResponse = bulkRequest.get();

Please help me in getting out of this issue.

Thanks & Regards,
Sanjay Reddy.

(David Pilato) #2

This is expected. This is how analysis process works.

You should read this chapter:

(system) #3