can i backport "pattern_replace" char filter into elasticsearch 0.19.9? - elasticsearch

our system is running elasticsearch 0.19.9.
recentyly i'm going to add a new mapping on it. what i need is merge multiple whitespaces into a single whitespace.
i do some search ,and find pattern_replace is what i need, code are like
"space_filter":{
"type":"pattern_replace",
"pattern":"\\s+",
"replacement":"\\s"
}
but the bad news is "pattern_replace" is not introduced until 0.90.*. so is there possibily to backport this function into the version i'm using?
really i don't want to upgrade this system the newest version, guessing it's time consuming, as i'm also using es-head and bigdesk. the version match thing might kill me.

Related

ElasticSearch 5.6 > 7.x Upgrade, is there an auto_generate_phrase_query Equivalant?

I'm upgrading my codebase's ElasticSearch from 5.6 to 7.x due to some features I'd like to explore.
I'm currently using GoLang & "github.com/olivere/elastic/v5" specifically.
However, auto_generate_phrase_query has been depreciated, and AutoGeneratePhraseQueries no longer works on v7 ("github.com/olivere/elastic/v7").
I've read to use explicit quoted queries, what is the equivalent to that in olivere? is there no setting i can set to true/false in ES when making requests to achieve this? Must i explicitly wrap my queries in quotation marks? Surely there must be a proper way to do this...
I found this: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-query-string-query.html
which states use [type=phrase] instead
In Olivere, i can set this via: Type("phrase"); is this a sufficient alternative?
The closest thing was actually using Phrase Queries. For anyone in the future coming back to find an answer.

Elasticsearch: Return same search results regardless of diacritics/accents

I've got a word in the text (e.g. nagymező) and I want to be able to type in the search query nagymező or nagymezo and it should show this text which contains that word in the search results.
How can it be accomplished?
You want to use a Unicode folding strategy, probably the asciifolding filter. I'm not sure which version of Elasticsearch you're on, so here are a couple of documentation links:
asciifolding for ES 2.x (older version, but much more detailed guide)
asciifolding for ES 6.3
The trick is to remove the diacritics when you index them so they don't bother you anymore.
Have a look at ignore accents in elastic search with haystack
and also at https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-analyzers.html (look for 'diacritic' on the page).
Then, just because it will probably be useful to someone one day or the other, know that the regular expression \p{L} will match any Unicode letter :D
Hope this helps,

ES 1.7.5 How to mimic match_none behavior?

Match_none was introduced in later versions, but there has to be a way to mimic the behavior in 1.7.5? Any leads would be appreciated.
Basically, I want to return a query which will match no documents, but my global aggregations would still run.
Found out I can use MustNot in combination with MatchAll (must not match all)

Elasticsearch: Replacement for Fuzzy Like This Query Deprecation

Reference to this link it said that the Fuzzy Like This (also Fuzzy Like This Query) will be deprecated in ES version > 1.6, and completely remove in version 2.
I'm using Elasticsearch version 1.5.1 and using a lot of FLT statement in my search query. I would like to upgrade the ES version to the current latest (1.7), but I could not find any suggest about FLT replacement when move to newer version? So I would like to ask, if any. And is it possible to use it when it is deprecated?
I found the following recommendation in the Elasticseach reference
:
The fuzzy_like_this or flt query has been removed. Instead use the fuzziness parameter with the match query or the More Like This Query.
Deprecated means that you can still use this feature without issues as long as you don't upgrade to version 2 or higher. I'm using version 1.7.1 and flt works fine. But the feature will no longer exist in version 2.x. For more details why they decided to remove it you can have a look at the relevant github thread.
I've run into the same problem. I borrowed a solution discussed on github https://github.com/elastic/elasticsearch/pull/10391
{
"multi_match" : {
"fields" : ["_all"],
"query" : "your search text",
"fuzziness" : "AUTO"}
}
multi_match has a number of other parameters you can use to improve the result.

Lucene.NET MatchAllDocsQuery doesn't honor document boost?

I have a Lucene index of document, all nearly identical (test 1, test 2, etc.) except that some have a higher boost than others. When using a default query (MatchAllDocsQuery OR .Parse(":") on the query parser) the documents come back in the order they went in every time. By adding a search term ("test" in this case), the document boost is apparent and the documents are sorted according to the boost. I can change the boost levels around and the new order is reflected in the results. All my code is pretty standard fair, I'm using a default Sort() is both cases.
I found that this same bug was reported and fixed in Lucene back in 2005-2006, and I checked my MatchAllDocsQuery.cs file (Lucene .NET 2.9.2) and it seems to have this change present, but the behavior is as described in the ticket above.
Any ideas what I might be doing wrong? Perhaps someone running the Java version has experienced this (or not)? Thanks.
Uh, don't I feel silly now. This is as-designed behavior. I guess. According to Lucene in Action, MatchAllDocsQuery uses a constant for the boost.

Resources