There is a ready elastic index used for autocompletions. I figured out how to filter by one word consisting of letters, but I can’t figure out how to make a search so that you can do a word search with spaces. For example, I can find in the names field for the request "Ivanov" a record like "Ivan Ivan Ivanovich," but if I ask the search for "Ivan Ivanov," then nothing will return. A piece of code:
SearchSourceBuilder search = SearchSourceBuilder.searchSource(); BoolQueryBuilder query = new BoolQueryBuilder(); String value = "Иванов Иван"; //строка которая ищется в индексе query.must(QueryBuilders.regexpQuery("names",".*" + value.replaceAll("([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\]|[&\\|]{2})", "\\\\$1") + ".*")); search.query(query);