简体   繁体   中英

How to translate a Solr query into Elasticsearch

I'm trying to express this Solr (Lucene) query in Elastic Search, but I'm not sure how:

q=field1:"value1"^10 OR field2:("value2a"^20 OR "value2b"^30)
group=true
group.field=fieldGroup

Is there a way to simply pass a Lucene query to ES, so I don't need to first translate it?

It's definitely possible to pass a Lucene query into Elasticsearch using a query_string query. Something like this should be plausible:

GET /_search
{
  "query": {
    "query_string": {
      "query": "field1:\"value1\"^10 OR field2:(\"value2a\"^20 OR \"value2b\"^30)"
    }
  }
}

You can also use aggregations to mimic your field collapsing: https://www.elastic.co/guide/en/elasticsearch/guide/current/top-hits.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM