Grok Pattern: How to check the condition in the pattern and set it to another value corresponding to the condition? - logstash

I want to write pattern grok for log file and I want to filter values ​​by range, for example request=0.1 will save this value as {request="0-0.5"}.
Is there any way to solve this like using if else?

Related

how to filter empty string in azure search

How can I filter out an empty string in a field?
I have tried search.ismatch() using "filter" option and regex using "search" option, but none of them worked.
As commented by juunas, $filter=FieldName ne '' should do the trick for you if your field is of type Edm.String. In addition if you want to filter out empty collection fields, you can do something like $filter=FieldName/any()
Also, to clarify search.ismatch() is a way to include search ranking in filter expressions. The matching criteria takes affect only on documents that satisfy the filter expression. For more details, look at https://learn.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search

SSIS Conditional Split - check if a string has a substring

I am wondering if there is a function in SSIS Conditional Split, that would tell me if the string in my datacell has a substring "XYZ" or not. The condition would look like this:
CheckIfValueContainsSubstring("XYZ")
Unfortunately I can't find such function. Is there any way of achieving the goal of separating the record which have the substring from the records which don't have it?
An important note: the substring can be anywhere (so the typical substring function doesn't work for me)
The correct expression for this in SSIS is FINDSTRING.
FINDSTRING( «character_expression», «string», «occurrence» )
MSDNArticle
Similar SO Question

Excel, using a second index match if first is empty

I was wondering if theres an easy way to setup a formula that is an index match one a sheet of data, and then if there was no match, look somewhere else.
I have new results which I want to look up from, then if not I have historical results to look up from. I dont want to combine the data as I dont want the historical numbers to change any averages in the new results.
I could use two columns each with a different index match and then some IF, OR statements but I'd like to know if theres a way of doing it all in one forumla.
Thanks
MATCH will return an error where a matching value is not found. This can be used to switch to an alternative match attempt, eg:
=IFERROR(INDEX(Sheet1!A:A,MATCH(C1,Sheet1!B:B,0)),INDEX(Sheet2!A:A,MATCH(C1,Sheet2!B:B,0)))

lucene filter: FieldCacheTermsFilter doesnot support space and special characters

I am using FieldCacheTermsFilter to filter out the results matching the field value as below.
Filter filter = new FieldCacheTermsFilter("city","toronto");
This works perfectly fine, whereas it doesn't work if the value has a space or special character in between like below.
Filter filter = new FieldCacheTermsFilter("city","new york");
Filter filter = new FieldCacheTermsFilter("type","b&b");
Is there way I can achieve this with any other filter.
PS: I am using FieldCacheTermsFilter for the reason that i want to search exactly on the word matching just "toronto" and not "greater toronto". I tried using TermFilter which extracts all the records containing toronto.
Your problem isn't the TermsFilter, it's your analyzer. Analysis should suit your needs for the field.
If you need to get exact matches on a whole field, you should index it as a StringField (or use KeywordAnalyzer, or set the field as untokenized). If you index with StandardAnalyzer, there is simply no good way to do what you are asking.

I need to check whether a string matches the pattern in postgresql

I need to check if a string is in the format '4.3.10'.
For example, If compare the strings 'AS45' or '456' or '4.1' with the above pattern, I should get a error message or boolean false.
Use the Postgres SIMILAR TO statement for pattern matching. In a query, the pattern matcher would like like this:
SELECT * FROM table WHERE column SIMILAR TO '[0-9]\.[0-9]\.[0-9][0-9]';
You can change the ranges within the brackets as needed.
http://www.postgresql.org/docs/current/static/functions-matching.html
We can use 'SIMILAR TO' operation.
IF we want to match more than one pattern at the same time use the following query.
SELECT * FROM table WHERE column SIMILAR TO '(.._|.|_|..|..|_..|_..|_..|..__)';
Separate each pattern with an 'OR' (|) operator.
In the above query I am comparing 9 different patterns.

Resources