ElasticSearchIndexProvider implements IndexProvider { protected String escapeSpecialCharacters(String queryString) { List<String> splittedTokens = Arrays.asList(queryString.split(" ")); return splittedTokens.stream().map(query -> { if (query.chars().filter(ch -> ch == ':').count() >= 0) { int separationChar = query.indexOf(':') + 1; return query.substring(0, separationChar) + processQuery(query, separationChar); } else { return query; } }).collect(Collectors.joining(" ")); } ElasticSearchIndexProvider(MetaModelStore metaModelStore,
                                      ElasticSearchContext elasticSearchContext,
                                      Analyzer analyzer); Client getClient(); @Override boolean isFreshIndex(KCluster cluster); @Override void index(KObject object); @Override void index(List<KObject> elements); IndexRequestBuilder createIndexRequest(ElasticMetaObject object); @Override boolean exists(String index,
                          String id); @Override void delete(String index); @Override void delete(String index,
                       String id); @Override List<KObject> findById(String index,
                                  String id); @Override void rename(String index,
                       String id,
                       KObject to); @Override long getIndexSize(String index); @Override List<KObject> findByQuery(List<String> indices,
                                     Query query,
                                     int limit); @Override List<KObject> findByQuery(List<String> indices,
                                     Query query,
                                     Sort sort,
                                     int limit); @Override long findHitsByQuery(List<String> indices,
                                Query query); @Override List<String> getIndices(); @Override void observerInitialization(Runnable runnable); @Override boolean isAlive(); void putMapping(String index,
                           String type,
                           MetaObject metaObject); Optional<MappingMetaData> getMapping(String index,
                                                String type); void putMapping(String index,
                           String type,
                           List<MetaProperty> metaProperties); @Override void dispose(); static final int ELASTICSEARCH_MAX_SIZE; static final String ES_TEXT_TYPE; static final String ES_KEYWORD_TYPE; }
@Test public void testEscapeSpecialCharacters() { String expected = "(+field:value AND +field2:\\+AAA123=) OR url:\"git\\:\\/\\/master@path\\/to\\/file\""; String queryString = "(+field:value AND +field2:+AAA123=) OR url:git: String escapedQueryString = this.provider.escapeSpecialCharacters(queryString); assertEquals(expected, escapedQueryString); }