need help for Odata query to get 'Configuration' value (3) for 'AppParamConfigs's "Name":"XYZ", - asp.net-web-api

with below Odata query
https://localhost:8080/odata/AppParams(1F2EE62A-8273-E811-81C6-185E0F9B6D7D)?$expand=AppParamConfigs
I'm getting all the AppParamConfigs like below,
{
"#odata.context":"https://localhost:8080/odata/$metadata#AppParams/$entity","Id":"1f2ee62a-8273-e811-81c6-185e0f9b6d7d","Name":"A","AppParamConfigs":[
{
"Id":"722fe62a-8273-e811-81c6-185e0f9b6d7d","Name":"ABC","Configuration":"2"
},{
"Id":"732fe62a-8273-e811-81c6-185e0f9b6d7d","Name":"XYZ","Configuration":"3"
}
]
}
Now I would like to get the Configuration value (3) for "Name":"XYZ" ?
I tried below, but not working
https://localhost:8080/odata/AppParams(1F2EE62A-8273-E811-81C6-185E0F9B6D7D)?$expand=AppParamConfigs($select=Name%20eq%20XYZ)

Try
https://localhost:8080/odata/AppParams(1F2EE62A-8273-E811-81C6-185E0F9B6D7D)?$expand=AppParamConfigs&$filter=Name eq 'XYZ'&$select=Configuration
You have to filter first then select.

Related

$elemMatch with $in SpringData Mongo Query

I am in the process of attempting to create a method that will compose a query using Spring Data and I have a couple of questions. I am trying to perform a query using top level attributes of a document (i.e. the id field) as well as attributes of an subarray.
To do so I am using a query similar to this:
db.getCollection("journeys").find({ "_id._id": "0104", "journeyDates": { $elemMatch: { "period": { $in: [ 1,2 ] } } } })
As you can see I would also like to filter using $in for the values of the subarray. Running the above query though result in wrong results, as if the $elemMatch is ignored completely.
Running a similiar but slightly different query like this:
db.getCollection("journeys").find({ "_id._id": { $in: [ "0104" ] } }, { journeyDates: { $elemMatch: { period: { $in: [ 1, 2 ] } } } })
does seem to yield better results but it returns the only first found element matching the $in of the subarray filter.
Now my question is, how can I query using both top level attributes as well subarrays using $in. Preferably I would like to avoid aggregations. Secondly, how can I translate this native Mongo query to a Spring data Query object?

Match query doesn't return the result

i am new to ES. I am using the ES 7.2 and i am making this query from Kibana. I write the below query to get all the documents who has "11" in field STATUS.
GET /index1/_search
{
"query":{
"match" : {
"STATUS":"11"
}
}
}
But the result includes as well the documents with STATUS other than 11. What do i do wrong? I want that the query returns just the docs with STATUS 11.
Try not to let more than one space between the GET /in... and your query.
Instead of:
GET ...
{
your query
}
Do this:
GET ...
{
your query
}
If you run it like you have it now, it only will run the GET petition, which is like you were telling it "Bring me everything".
Hope this is helpful! :D

Correct syntax for adding a filter aggregation in a Kibana visualization as a JSON input (filtering for a specific property value)

I am trying to perform the simplest filter for a specific property value, as a JSON input, in a Kibana visualization, thoroughly without success.
I can't, to my surprise, find concrete examples in doing that (have been searching for a couple of minutes now).
Say we have a document with the following structure:
{
a: true,
b: 10
}
How can I add a Filter aggregation for all documents with a = true ?
I tried using "script", "query", "filters" api, but all give me parse errors. My filter jsons are all valid, my problem is with the exact syntax elastic is expecting, but all examples I found out there and tried - give me parsing errors (after making the amendments to my index structure).
Kibana's version: 6.4.3
How is this accomplished ?
An example:
POST /sales/_search?size=0
{
"aggs" : {
"docs" : {
"filter" : { "term": { "a": "true" } },
}
}
}
Here is the link to the official documentation with example.

Elasticsearch - how to append term?

Is there a way to append term into an array of values?
For example if my document looks like this:
{
"items": ["item1", "item2", "item3"]
}
I want to append "item4" and "item5" to it.
I must do it in 2 queries? one to load the current list of values, and on to update that list? or is there more elegant way that will let me append those items in one query?
I am trying to do it with elastic4s like this:
client.execute(ElasticDsl.update id id in indexName / documentType script {
script(s"ctx._source.items += tag").params(Map("tag"->"item4"))
})
In order to use the above code snippet, I need to enable groovy scripts, and I am not sure how to do it with multiple items.
Any idea?
Here is a full example of how you could achieve this.
Merge new values to array and make it unique after:
DELETE test/test/1
POST test/test/1
{
"terms":["item1", "item2", "item3"]
}
GET test/test/1
POST test/test/1/_update
{
"script" : " ctx._source.terms << newItems; ctx._source.terms = ctx._source.terms.flatten().unique()",
"params" : {
"newItems" : ["a","b"]
}
}
make sure you have scripting enabled in server config
user:/etc/elasticsearch# head elasticsearch.yml
script.inline: true
script.indexed: true
...
Try using 'terms' filter in your code.If you are using NEST then following link will be useful https://nest.azurewebsites.net/nest/writing-queries.html

Why elasticsearch request body query analyzer not working?

When I use the simplest get query ( /index/_search?q=北京 ) , the results seems normal. But when I use the request body query , like below:
{
'query': {
'query_string':{
'query': '北京'
}
}
}
It seems elasticsearch not use analyzer I specific by the mapping setting, even I add the analyzer setting in the query body.
Can anyone help me find out what's wrong? Thank you.

Resources