I have a simple task:
Get all the items from an elastic index with status 'paid' or 'done' for the last week.
What I tried is this:
GET /my_index/_search?q=((status:paid or status:done) and (created_at > "now-7d/d"))
The interesting part is, if I do
GET /my_index/_search?q=((status:paid or status:done)
I get around 4k results, but if I do the whole query, I get 600k. It appears, that if I add the 2nd part, something stops to work properly.
I have tested the query in the discover tab of Kibana and it is working properly there, but for some reason, it does not with the API. Any help will be appreciated.
PS: I cannot do the query in the body, as there are additional aggregate filters there, that I at least haven't found a way to combine with the above filters.
You're on the right track but you have three tiny syntax mistakes that make the query not work as intended.
Change (created_at > "now-7d/d") to (created_at :> "now-7d/d")
Change the and into AND, Currently (x and y) are being parsed into x OR and OR y which is why you're getting so many results.
Change the or into OR, Same concept you're getting false matches due to it.
To summarize change your query into this:
GET /my_index/_search?q=((status:paid OR status:done) AND (created_at :> "now-7d/d"))
Related
I have a query which is part of several queries in a tab.
I want to modify each of the queries by adding exclusions.
But when I copied the first query and put it in a new tab for testing, the table was underlined in red, and when you hovered over the text, it said 'Undefined table.'
Does anyone know why this would happen when the query is moved to a new tab?
I hadn't made any changes, yet!
The query looks like this:
SELECT
CONCAT ('DX COST',null) as "R List",
TRIM(T$SKU) as "SKU",
T$PDDP as "Price"
FROM TRITON.DDIITM001145
WHERE T$GSIZ NOT in ('LED','ODS');
The part TRITON.DDIITM001145 part of the query was underlined in red, when I copied the query and moved it into a new tab.
I've never seen that happen before?
Also, I'm not sure how to put the whole query in code, on here? I used the {} / code sample button to paste what you can see, but it didn't include the FROM statement?
Any thoughts would be appreciated!
Thank you!
In your new query tab, are you using the same database? Because our parser checks the data dictionary to see if it can find a view, table, or synonym called DDIITM001145
If we can't find it, you get the squiggly 'warning.'
This is ONLY a warning. It won't prevent you from running the query. It's just a heads-up that it might not work before you trying running it.
If you look at the Log panel, you can see where we query the database looking for your table.
I query with a count less than the total to make it paginate:
https://healthcare.googleapis.com/v1/projects//locations//datasets//fhirStores//fhir/Encounter?_sort=date&_count=5&practitioner=abcdefg&subject:missing=false&patient:Patient.name=John&patient:Patient.name=Doe&_include=Encounter:patient
And the returned next link has combined the 2 Patient.name values, make it be an OR instead of an AND:
.../?_count=5&_include=Encounter%3Apatient&_sort=-date&patient%3APatient.name=John%2CDoe&practitioner=abcdefg&subject%3Amissing=false&_page_token=
Is it right that it combines the 2 values for Patient.name? I still want the next page of results to have those 2 conditions ANDed together, not ORed. How do I get that?
This looks like a bug. I see that it works without the chained search, e.g. if I do Patient?name=John&name=Doe, I get a next link that has the correct AND.
For the chained search, the actual results seem to be from the AND query but the pagination links are incorrectly converted to OR.
I have reported this issue internally.
As a workaround, it appears that if you use the _page_token value from the link and run the query with the conditions you want and &_page_token=[value], it does return the correct next page.
The filter query in this flow doesn't appear to be working as expected. I know for certain that the items it emails out afterwards have the first two toggles set to false. Is there something in the syntax that I'm missing? Or possibly in the date/time comparisons? This is my first dive into Power Automate, and its with someone elses flow. So any insight is greatly appreciated.
This is an example of what it looks like after running, and getting items where Confirmed = false.
Thank_x0020_You_x0020_Sent eq 'false' and Confirmed eq 'true' and EventDate lt '2021-07-20T00:00:00.0000000' and EventDate ge '2021-07-19'
Assuming EventDate is a DateTime data type, instead of the raw outputs try:
formatDateTime(outputs('<actionName>'), 'yyyy-MM-ddTHH:mm:ss')
It seems to me that having so many conditions for the query is not a good idea and less if dates are used.
It is better to do the query with one or two conditions and then filter the received data within an apply to each step
The first two conditions are Yes/No Columns, so they need to be 0 or 1 (not true/false) Silly mistake, don't know how I missed that.
I agree with both previous comments for cleaning up the query in general.
Below is the url which will hit the middle layer then middle layer will form the solr query and fire it.
listing?limit=20&q=Chennai~Tambaram~450000~25000000~24
Chennai-->city
Tambaram-->locality
450000~25000000-->price_min and max
24--lux_ amenities
here other than lux_amenities I am using fq for all other things,so the problem here is sorting.
I am sorting the results using bscore and relscore likebelow,
$bscore desc,$relscore desc
first time it works fine.
above bscore and relscore will change based on lux_amenities but lux_amenities is neither part of fq nor q.So if second time we are changing the lux_amenities alone and firing the query means it is giving the result in same order as first query even the bscore and relscore are different.
So I disabled the queryResultCache,
-->
Now it is working fine. But I need a better solution than disabling this for all queries.For eg, I want to disable this for few queries alone not for all.
Could someone help me please..
im trying to run an hql query which aggragets (sum) number of transactions made on a specific account, i dont need a group by since my where clause has a specific account filter (where account = :account)
i do, however, want to return the aggregated value only if it is smaller/bigger than some given value.
when im adding 'having' after the where clause without 'group by' im getting an error -
unexpected token: having
in native sql i succeeded adding 'having' without group by
any ideas on how to make it work with hql?
thanks alot
The reason why databases don't let you mix grouped columns with non-grouped and non-aggregated ones is, that for non-grouped/non-aggregated columns it would have to choose one row's value per group, but doesn't know how to pick one.
If you don't care, then you could just leave it away and if it doesn't matter because they're all the same, you could group by them, too.
It is not hql, but if you have native query, then run it like:
Query query = session.createSQLQuery("select, *** ,... blah blah")
//set If you need
query.setParameter("myparam", "val");
List result = query.list();
In my eyes this is nonsense. 'having' is done for conditions on a 'group by' result. If you don't group, then it does not make much sense.
I would say HQL can't do it. Probably the Hibernate programmers didn't think of this case because they considered it as not important.
And anyway, you don't need it.
If it is a simple query, then you can decide in your java code if you want the result or if you don't need it.
If it is in a subselect, then you can solve the problem with a where condition in the main select.
If you think it is really necessary then your invited to give a more concrete example.