Я пытаюсь найти совпадение имени с учетом регистра. Когда я попробовал код ниже, он работал, как и ожидалось, без учета регистра.
HashMap<String, String> data = new HashMap<String, String>();
data.put("GroupId", "3");
data.put("GroupName", "testGroup three");
data.put("CreatedDateTime", "20180115130026757+0000");
data.put("UpdatedDateTime", "20180115130026757+0000");
data.put("Createdby", "3");
data.put("GroupUser", "{1,2,3,4}");
data.put("status", "active");
String mapping = {"typename":{"properties":{
"GroupName":{"type":"text","index":"not_analyzed"},
"Createdby":{"type":"text","index":"not_analyzed"},
"GroupUser":{"type":"text","index":"not_analyzed"},
"UpdatedDateTime":{"type":"text","index":"not_analyzed"},
"CreatedDateTime":{"type":"text","index":"not_analyzed"},
"GroupId":{"type":"text","index":"not_analyzed"},
"status":{"type":"text","index":"not_analyzed"}}}}
client = new PreBuiltTransportClient(settings).addTransportAddresses(new TransportAddress(new InetSocketAddress(ipaddress, port)));
//inserting record
IndexResponse response = client.prepareIndex(indexName, typeName).setSource(data).get();
//inserting mapping
client.admin().indices().preparePutMapping(indexName)
.setType("typeName")
.setSource(mapping, XContentType.JSON)
.get();
Чтобы найти значение с учетом регистра, я обнаружил, что использовать индекс как not_analyzed. Я попробовал следующее
HashMap<String, String> data = new HashMap<String, String>();
data.put("GroupId", "3");
data.put("GroupName", "testGroup three");
data.put("CreatedDateTime", "20180115130026757+0000");
data.put("UpdatedDateTime", "20180115130026757+0000");
data.put("Createdby", "3");
data.put("GroupUser", "{1,2,3,4}");
data.put("status", "active");
String mapping = {"typename":{"properties":{
"GroupName":{"type":"text","index":"not_analyzed"},
"Createdby":{"type":"text","index":"not_analyzed"},
"GroupUser":{"type":"text","index":"not_analyzed"},
"UpdatedDateTime":{"type":"text","index":"not_analyzed"},
"CreatedDateTime":{"type":"text","index":"not_analyzed"},
"GroupId":{"type":"text","index":"not_analyzed"},
"status":{"type":"text","index":"not_analyzed"}}}}
client = new PreBuiltTransportClient(settings).addTransportAddresses(new TransportAddress(new InetSocketAddress(ipaddress, port)));
//inserting record
IndexResponse response = client.prepareIndex(indexName, typeName).setSource(data).get();
//inserting mapping
client.admin().indices().preparePutMapping(indexName)
.setType("typeName")
.setSource(mapping, XContentType.JSON)
.get();
Я получаю исключение, как показано ниже
java.lang.IllegalArgumentException: Could not convert [GroupName.index] to boolean
Я хочу выполнить два сценария ниже:
1. Find by case sensitive
2. Find by case insensitive.
Версия эластичного поиска — 6.1.2.
Любая помощь очень ценится.
ОБНОВЛЕНИЕ-1
Согласно @Val, я изменил код на:
HashMap<String, String> data = new HashMap<String, String>();
data.put("GroupId", "3");
data.put("GroupName", "testGroup three");
data.put("CreatedDateTime", "20180115130026757+0000");
data.put("UpdatedDateTime", "20180115130026757+0000");
data.put("Createdby", "3");
data.put("GroupUser", "{1,2,3,4}");
data.put("status", "active");
String mapping = {"typename":{"properties":{
"GroupName":{"type":"keyword"},
"Createdby":{"type":"keyword"},
"GroupUser":{"type":"keyword"},
"UpdatedDateTime":{"keyword":"text"},
"CreatedDateTime":{"keyword":"text"},
"GroupId":{"type":"keyword"},
"status":{"type":"keyword"}}}}
client = new PreBuiltTransportClient(settings).addTransportAddresses(new TransportAddress(new InetSocketAddress(ipaddress, port)));
client.admin().indices().prepareCreate("indexName").get();
//inserting mapping
client.admin().indices().preparePutMapping(indexName)
.setType("typeName")
.setSource(mapping, XContentType.JSON)
.get();
//inserting record
IndexResponse response = client.prepareIndex(indexName, typeName).setSource(data).get();
Теперь я могу вставить. Но когда я ищу значение a в GroupName, результат пуст.
data
? - person Val   schedule 20.02.2018