Closed fissehab closed 5 years ago
does this do what you want? https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-match-query-phrase.html
Thanks. But how can I use that in R to search any of the phrases shown above?
library(elastic)
connect()
shakespeare <- system.file("examples", "shakespeare_data_.json", package = "elastic")
invisible(docs_bulk(shakespeare))
body_match <- '{
"query": {
"match" : {
"text_entry": "the men"
}
}
}'
body_match_phrase <- '{
"query": {
"match_phrase" : {
"text_entry": "the men"
}
}
}'
Search("shakespeare", body = body_match)$hits$total
Search("shakespeare", body = body_match_phrase)$hits$total
I have many phrases and also the phrases are dynamic. They are search input on a shiny app . Using query string looks easier to implement if it is possible to search phrases. But with the above approach you provided, how can I search many phrases? By just repeating the "match_phrase" for each phrase?
i'm not sure. i'd google/search stackoverflow. or ask on the elasticsearch discussion forum https://discuss.elastic.co/
hopefully you've found an answer, it sort of falls out of scope of this package as it's more of a how to for Elasticsearch database itself
I want to search exact phrases. How can I do it? Basically, I want to use something like below
"query": { "query_string" : { "type": "phrase", "query" : "(cloud computing) OR (supply chain)" } }