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.

Way to search exact string?

See original GitHub issue

Hi,

In kibana, we can search exact string by wrapping it by double quotation marks. It seems s = s.query('match', content="Donald Trump") is searching for Donald or Trump.

Using dsl-py how can we search exact string?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
honzakralcommented, Jun 2, 2017

Hi, kibana uses the query_string query so you can have the exact same functionality by using that: s = s.query('query_string', query='"Donald Trump"')

I would however recommend more granular approach using either a phrase or terms queries - phrase (0) is useful if the string you are looking for is somewhere in a field, but not exactly the match, it will also work with type text (analyzed).

If you want to do true exact matching you need to use keyword type fields and a term query (1). That will do exact match against a field: s = s.query('term', full_name="Donald Trump")

Hope this helps

0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html 1 - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

3reactions
honzakralcommented, Oct 8, 2018

@balaa you cannot really have a universal search like that for exact matches since it depends on the mappings also you cannot effectively search for an exact substring. The best approximation would be to use a phrase query as mentioned.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tip #5: Search for an Exact Phrase - InformIT
When you're searching for an exact phrase, you won't get the best results simply by entering all the words in the phrase as...
Read more >
Searching for *exact* string on Google or other search engines
Try your search with the SymbolHound search engine.
Read more >
Google Tips and Tricks: Limit Search - Exact Phrase - LibGuides
Insert quotation marks to search for a specific phrase or word. This can help you find quotes, search for song lyrics, or identify...
Read more >
How do I make Google search for a nice short EXACT phrase
So how do I search for the EXACT phrase "pick-up truss" ? Even searching for. "pick-up truss" -pickup -truck -trash -"pick up".
Read more >
Searching for an Exact Term - Coveo Documentation
In the search box, type the exact desired term preceded by the plus sign ( + , the exact match prefix), and then...
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