question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query always overwrites

See original GitHub issue

NEST/Elasticsearch.Net version: 2.3.1

Elasticsearch version: 2.3.2

Description of the problem including expected versus actual behavior: If you are building a SearchDescriptor and call .Query([query lambda]) on it, it overwrites the current query. This is inconsistent with the behaviour experiences when building a MultiSearchDescriptor where .Search([name], [search lambda]) adds another search.

I know it’s not completely the same, but often you just want to add to a query. Personally I expected the argument of the lambda method in .Query([query lambda]) to be the current query, and not a completely new one every time. (I also expected that every call to a method on some descriptor to be side effect free, but I got smarter and now see the value of the current approach, despite the lack of documentation)

For now I use an extension method to build my default query, and let this extension method take an optional argument of an additional query. It would be nice if the query method could take an additional boolean argument to tell it whether to merge this query or overwrite.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
beruiccommented, Jun 20, 2016

@gmarz I agree completely, as my comment from 20 may also indicates 😃

0reactions
gmarzcommented, Jun 17, 2016

@beruic that’s the correct way to go about it, using the bool operators.

I think .Query() being additive, or merging with the existing query would not be intuitive at all.

Closing this, but feel free to re-open if you still think otherwise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Avoid "Overwrite Data" Error With Query Function
Hey everyone,. Is there a way to automatically insert a row every time my query function returns an additional row of data as...
Read more >
Overwrite values every time vs query to see if value has ...
It seems like your query could be re-written as follows, without the need to put anything into a local variable. UPDATE dbo.
Read more >
Query with filter overwriting other query results that used a ...
Problem: If I make two separate queries with a different value for first, they overwrite each other's results because the same UserGroup is ......
Read more >
wp query - Is temporarily overwriting $wp_query a bad idea?
Overwriting the Main Query is almost always a bad idea and will become a headache later. The wp_reset_query() function isn't the biggest ...
Read more >
Can I Create An Append Query That Overwrites - Microsoft
I would like to create an export query that writes from one Access database to another and overwrites the information needs to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found