How to escape character in power automate with dynamic data from query - dynamics-crm

I am trying to filter rows with: name eq 'nameFromQueryData'
One name is breaking the filter: Paul O'Meefe
Its due to the filter needing to escape the ' inside the name. Its reading it as: name eq 'Paul O' (end string) Meffe' (start string) = error
Since this is dynamic data, I cant just use the escape character O/'.
So how would one go about escaping it?

Try using fetchxml instead - it's a lot more adaptable and forgiving instead of an odata query in Power Automate
enter image description here

Related

Oracle HCM REST API - get query with '&' query param

I am trying to get organizations resource for Name = 'G&A' using the following API
https://xxx/hcmCoreSetupApi/resources/11.13.18.02/organizations/?onlyData=true&q=Name='G&A'
But getting an error "URL request parameter A' cannot be used in this context."
Thank you for the help in advance
The ampersand & character is used as a separator between query parameters. If you want to pass an ampersand as part of a query parameter's value then use the equivalent hexidecimal code %26 instead of &:
https://xxx/hcmCoreSetupApi/resources/11.13.18.02/organizations/?onlyData=true&q=Name='G%26A'
However, that is still invalid as you have too many equals = characters in that string; so did you intend to have three parameters named onlyData, q and Name? Then you would encode them like this:
https://xxx/hcmCoreSetupApi/resources/11.13.18.02/organizations/?onlyData=true&q=&Name='G%26A'
Or, if you really had intended to have two parameters named onlyData, q=Name then you would need to encode the equals = character in the parameter name as well:
https://xxx/hcmCoreSetupApi/resources/11.13.18.02/organizations/?onlyData=true&q%3DName='G%26A'
Or, if Name= is part of the value not the key then:
https://xxx/hcmCoreSetupApi/resources/11.13.18.02/organizations/?onlyData=true&q=Name%3D'G%26A'

elasticsearch - fulltext search for words with special/reserved characters

I am indexing documents that may contain any special/reserved characters in their fulltext body. For example
"PDF/A is an ISO-standardized version of the Portable Document Format..."
I would like to be able to search for pdf/a without having to escape the forward slash.
How should i analyze my query-string and what type of query should i use?
The default standard analyzer will tokenize a string like that so that "PDF" and "A" are separate tokens. The "A" token might get cut out by the stop token filter (See Standard Analyzer). So without any custom analyzers, you will typically get any documents with just "PDF".
You can try creating your own analyzer modeled off the standard analyzer that includes a Mapping Char Filter. The idea would that "PDF/A" might get transformed into something like "pdf_a" at index and query time. A simple match query will work just fine. But this is a very simplistic approach and you might want to consider how '/' characters are used in your content and use slightly more complex regex filters which are also not perfect solutions.
Sorry, I completely missed your point about having to escape the character. Can you elaborate on your use case if this turns out to not be helpful at all?
To support queries containing reserved characters i now use the Simple Query String Query (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
As of not using a query parser it is a bit limited (e.g. no field-queries like id:5), but it solves the purpose.

Oracle text curly braces behavior

I'm using oracle text to do a readahead (according to the spec writer) in the search bar.
Basically, a user can start typing text and we fill the suggestions bar with likely matches.
I tried using oracle text for this, and ran into some issues, and the latest one being:
Table contains this entry for answertext: ... we offer many pricing options ...
SELECT
questiontext as qtext,
answertext as text,
questionid FROM question
WHERE contains(answertext, '{pric}', 1) > 0
;
This query returns nothing. But using {pricing} will return the correct result.
And suggestion why this is happening would be great!
Edit: just wanted to add that using stemming does not work for me because the user wants to differentiate between "report" and "reporting" and they want the matching substring to be highlighted which can be done if I can find the substring among the returned results.
Edit 2: I have my guess, that oracle tokenizes each word using word boundary of some sort in the index, and thus without any wildcards it looks for a token that equals = 'pric' and therefore does not find it (because there is a token 'pricing'). So, if that guess is correct I would love if someone can chime in for how I can make the query above work with the example entry while still maintaining whitespace so if type 'pricing options' it should return but if i type 'many options' it should not...
CONTAINS operator supports wildcards and fuzzy text search. Try:
SELECT * FROM question WHERE contains(answertext, '{pric%}', 1) > 0;
or
SELECT * FROM question WHERE contains(answertext, 'fuzzy({pric})', 1) > 0;
But with fuzzy "prize" will also match your search criteria.
To highlight found substrings you can use CTX_DOC.MARKUP.

How do I concatenate string in Pentaho spoon?

I am a newbie to Pentaho (installed today). I was able to do basic transformation in Spoon. Now I need to do some stuff, which I can't figure out how.
my input looks like
2012-09-17|garima|fbhjgjhgj87687jghgj88jgjj|garima#1347868164626|::ffff:120.56.132.137
3rd field is an ID, for which I need to get some information from a REST API
http://api.app.com/app/api/v1/feature/fbhjgjhgj87687jghgj88jgjj
What do I need to do in Spoon to get this done?
Also, data return will be in json format. how do I parse that?
You should first get your input with a CSV File Input using | as delimiter. Then you can get the 3rd field as a string.
Next you probably need to remove all spaces from this string with a String operations step. Look at the Remove special character column, and select space.
Then you need to concatenate it with your http address http://api.app.com/app/api/v1/feature/. For this you'll use a Calculator step. At this step first create a new temporary field tmpAddr, with operation Define a constant value for ... (or something like this, sorry my spoon is in portuguese). At the Field A column you'll write your http address. It's a good practice, after you make this work, to set your address as a system variable so if it changes you don't need to replace it everywhere on your transformations (look at menu Edit -> System Variables).
Now on the same Calculator step create another field, let's say MyAddress, with operation A+B. Choose for Field A the field tmpAddr you just created, and for Field B the 3rd field from your input.
Now on your stream you should have the full address as a field MyAddress. Connect a REST client step. Mark Accept URL from field and choose field MyAddress as URL Field Name. Set Application Type to JSON. Set Result Fieldname as MyResult.
If you need further JSON parsing you can add a Json input step. Set Source is defined in a field and select field MyResult as Get Source from field.
An alternate approach is to use the "Replace in String" step to append the string.
Set 'use RegEx' to Y
Set 'Search' to (.*)
Set 'Replace with' to http://api.app.com/app/api/v1/feature/$1
Set 'Whole Word' to Y
The parentheses in the regex set up a capture group that you can then insert into your replacement string with the $X syntax

Using AND, OR and NOT in Solr Query

I am trying a Solr query which is like this
+field1:* AND (field2:1 OR field2:10) NOT(field3:value1 OR field3:value2)
But field3 part of the query is not making any impact. It still brings record which has value1 or value2 in field3
Why is this?
Try this
+field1:* +(field2:1 OR field2:10) -(field3:value1 OR field3:value2)
I think a AND / OR is missing between the two last blocks. It would then become something like :
+field1:* AND (field2:1 OR field2:10) AND NOT(field3:value1 OR field3:value2)
You need to urlencode certain characters in the Solr query to meet UTF8 standards and the + (plus) symbol is one of them, as well as space, brackets etc.
Things to encode are:
Space => +
+ => %2B
( => %28
) => %29
and so forth, you can see an example of an encoded URL on the SOLR website:
https://wiki.apache.org/solr/SolrQuerySyntax
Try:
str_replace(array('+','(',')',' '), array('%2B','%28','%29','+'), '+field1:* (field2:1 field2:10) -(field3:value1 field3:value2)');
This should give you:
%2Bfield1:*+%2B%28field2:1+field2:10%29+-%28field3:value1+field3:value2%29
IF your default query parser operation is set to OR, then any space between fields will be interpreted as an OR operator.
The above result is far from clean & readable, but it is a correctly formatted UTF8 string which Solr requires you to pass to it. You'll notice the difference as soon as you run it.
Why str_replace instead of urlencode? Well you can use urlencode because it will correctly format the string as UTF8 but it might format some string components that don't need to be encoded.

Resources