I want to know how can I search for 2 key:value pairs with the browser on localhost:9200
For Example: want to combine country=CAN AND brand=V
_source": {
"country": "CAN",
"brand": "V",
"leadID": 10333,
"datetime": 1442247315000
}
... and so on
I tried this uri with the "default_operator" set to AND:
http://localhost:9200/_search?default_operator=AND&q=country:CAN&q=brand:V
In the response I got country=CAN with brand=V, but I also got country=PRT with brand=V. So it did an OR operation instead of AND operation.
Try this http://localhost:9200/_search?default_operator=AND&q=country:CAN AND brand:V
Your browser will translate it to http://localhost:9200/_search?default_operator=AND&q=country:CAN%20AND%20brand:V
meaning you combine the two conditions into one: q=country:CAN AND brand:V.
Related
I am using Alteryx to take an Excel file and convert to JSON. The JSON output I'm getting looks different to what I was expecting and also the object starts with "JSON": which I don't want to happen and I would also like to know how/which components I would use to map fields to specific JSON fields instead of key value pairs if I need to later in the flow.
I have attached my sample workflow and excel which are:
Excel screenshot
Alteryx test flow
JSON output I am seeing:
[
{
"JSON": "{\"email\":\"test123#test.com\",\"startdate\":\"2020-12-01\",\"isEnabled\":\"0\",\"status\":\"active\"}"
},
{
"JSON": "{\"email\":\"myemail#emails.com\",\"startdate\":\"2020-12-02\",\"isEnabled\":\"1\",\"status\":\"active\"}"
}
]
What I expected:
[{
"email": "test123#test.com",
"startdate": "2020-12-01",
"isEnabled": "0",
"status": "active"
},
{
"email": "myemail#emails.com",
"startdate": "2020-12-02",
"isEnabled": "1",
"status": "active"
}
]
Also, what component would I use if I wanted to map the structure above to another JSON structure similar this one:
[{
"name":"MyName",
"accounType":"array",
"contactDetails":{
"email":"test123#test.com",
"startDate":"2020-12-01"
}
}
} ]
Thanks
In the workflow that you have built, you are essentially creating the JSON twice. The JSON Build creates the JSON structure, so if you then want to output it, select your file to output and then change the dropdown to csv with delimiter \0 and no headers.
However, try putting an output straight after your Excel file and output to JSON, the Output Tool will build the JSON for you.
In answer to your second question, build the JSON for Contact Details first as a field (remember to rename JSON to contactDetails). Then build from there with one of the above options.
I'm trying to execute an query on my users of my Azure B2C Active Directory.
So far everything works fine with the following query:
https://graph.windows.net/myTentant/users?$filter=
startswith(displayName,'test')%20
or%20startswith(givenName,'test')%20
or%20startswith(surname,'test')%20
or%20startswith(mail,'test')%20
or%20startswith(userPrincipalName,'test')
&api-version=1.6
The thing about that is, that this properties are just simple values like this:
"displayName: "testValue",
"givenName": "testValue",
"displayName: "testValue",
"surname": "testValue",
"mail: "testValue",
"userPrincipalName": "testValue",
In my case I need to use one more statement, in which I need to check an array if it contains 'test' like the others. This array look like that:
"signInNames": [
{
"type": "emailAddress",
"value": "test#mail.com"
}, {
"type": "emailAddress",
"value": "test2#mail.com"
}
]
I Already search in the official documentation but had no luck....
Any ideas?
In theory, we should use the following format to determine whether the value starts with "test".
GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:startswith(c/value, 'test'))
Unfortunately, it will show an error: value only supports equals-match. PrefixMatch is not supported.
And the contains string operator is currently not supported on any Microsoft Graph resources. So we can't use contains neither.
You need to use equal to find the exact match data:
GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:c/value eq '***')
It is not a solution. But there seems not to be a way to meet your needs.
Maybe you could query all the signInNames and handle them in your code.
I created an Azure index for my DocumentDB collection, and it seems to be working fine. The index has properties for a user account like FirstName, LastName, and Username. The problem is the default tokenizer seems to be tokenizing the Username field. While I want token matches for the first two fields, I'd like character matching for the usernames. Is there an easy way to achieve this through the Azure portal? If not, how can I achieve this?
Adding another answer based on your above comments. So basically in the best case, what you want to do is prefix, suffix and wildcard search. So if the username was user246392, you could find it by typing "use", "392" or even "er246". The prefix is easy, because you could search use* and it would find it.
Kendra Little did a really nice blog post on how to leverage RegEx with Azure Search, which can allow you to do the full wildcard part of your ask (i.e. search for "392").
If you wanted to do the suffix search, you can do a trick that is quite efficient where you create a new field that would be a custom analyzer that would index the words in opposite order. Here is an example of a index schema that would allow this (over suffixName field)
{
"name":"people",
"fields": [
{ "name":"id", "type":"Edm.String", "key":true, "searchable":false },
{"name": "suffixName", "type": "Edm.String", "searchable":true, "indexAnalyzer":"suffixIndexingAnalyzer", "searchAnalyzer":"reverseText"}
],
"analyzers": [
{
"#odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"name": "suffixIndexingAnalyzer",
"tokenizer": "keyword_v2",
"tokenFilters": [
"asciifolding",
"lowercase",
"reverse",
"my_edgeNGramForSuffix"
],
"charFilters": []
},
{
"#odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"name": "reverseText",
"tokenizer": "classic",
"tokenFilters": [
"lowercase",
"reverse"
],
"charFilters": []
}
],
"tokenFilters":[
{
"#odata.type": "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2",
"name": "my_edgeNGramForSuffix",
"minGram": 2,
"maxGram": 25,
"side": "front"
}
]
}
Can you give us an example of what you would want to do over this username field? I am not sure what you mean by character matching. Is it a RegEx based character match? If so, perhaps a custom analyzer that enabled RegEx searched might help for this field? Please note, RegEx is not as performant as typical indexing as we would need to scan the entire content as opposed to going to the inverted index to find token matches.
I am filtering on an array of addresses. A type attribute determines the address category (POSTAL,RES,WORK etc). I need to filter only the POSTAL and RES address from this array.
I tried to use the filer array action , but it can take only one filter condition.
Can it be edited in the code view to achieve multiple filter conditions ? If yes, what is correct syntax for it.
{
"Name": "Douglas Adams",
"Address": [
{
"Type": "POSTALS",
"street_address": "42",
"city": "Milky Way",
"state": "HI"
},
{
"Type": "RES",
"street_address": "1618",
"city": "Golden ratio",
"state": "MA"
},
{
"Type": "BILLING",
"street_address": "1618",
"city": "Golden ratio",
"state": "MA"
}
]
}
Can it be edited in the code view to achieve multiple filter conditions ?
In shot, Yes. Logic Apps now supports multiple rules in a condition block. Here is a issue you could refer to.
Because I do not know the action above your Filter array, so I will give you a similar syntax (e.g. http body is equal 'bbb' and http headers is equal 'aaa') as below:
#and(equals(triggerOutputs()['headers'],'aaa'), equals(triggerBody(),'bbb'))
You could modify to your situation and fill into edit in basic mode in Filter array.
For more details, you could refer to this thread.
I have following problem
I have a field mapping update to an index .Payload is complex where
I have:
{
"type": "abc",
"Party": [{
"Type": "abc",
"Id": "123",
"Name": "manasa",
"Phone": [{
"Type": "Office",
"Number": "12345"
}]
}]
}
And now I want to create a field for an index. The field name is phonenumber of type Collection(Edm.String)
where mapping is
{
"sourceFieldName" : "/Party/Phone/Number",
"targetFieldName" : "phonenumber",
"mappingFunction" : { "name" : "jsonArrayToStringCollection" }
}
In http post body
But still after indexing i get phone number result as null.That means the mapping went wrong.If you see the phone number in source json, it is inside a json array and it itself is an array and result needs to get stored inside a collection of a string.Is it possible how can I achieve this?
If this is not possible I atleast want field mapping till phone array ie., /Party/Phone/
If i index complete party array as a text, I get an error while running the index saying:
"Field 'partydetails' contains a term that is too large to process. The max length for UTF-8 encoded terms is 32766 bytes. The most likely cause of this error is that filtering, sorting, and/or faceting are enabled on this field, which causes the entire field value to be indexed as a single term. Please avoid the use of these options for large fields."
Can someone please help!
If party would have been a Json object than an array and phone would have been only a string array for example
{
"type": "abc",
"Party": {
"Type": "abc",
"Id": "123",
"Name": "manasa",
"Phone": [{
"12345",
"23463"
}]
}
}
Then I could have mapped
{
"sourceFieldName" : "Party/Phonenumber",
"targetFieldName" : "phonenumbers",
"mappingFunction" : { "name" : "jsonArrayToStringCollection" }
}
It map as collection of type odata EDM.string.
So to put this in better and straight forward way,
Either transform your json to something flatter (the example that I
gave above) or
Use the proper index incase if you know before inhand as
#Luis Cabrera said,
“sourceFieldName”: “/Party/0/Phone/0/Type
It is a limitation from azure search side.
Note that Party and Phone are arrays, so the field mapping you mention won't work.
You will need to index into the specific element. For example:
{
"sourceFieldName": "/Party/0/Phone/0/Type",
"targetFieldName": "firstPhoneNumberTypeOfFirstParty"
}
You may want to give that a shot.
Thanks!
Luis Cabrera | Program Manager | Azure Search