How do I check if field contains certain string?

How do I query an index to return documents where a field contains only a certain string (analagous to SQL contains). This is the corresponding SQL query I would like to do in ElasticSearch. SELECT * FROM table WHERE CONTAINS(fieldname, string).

To use REST API, for example


 GET /metricbeat-8.3.1/_search?size=1
{
  "query": {
    "wildcard": {
      "agent.name": "*file*"
    }
  }
}

1 Like

I dont understand why not.

I'm not asking how to make a query or using the REST API. I'm asking about how to do a SQL CONTAINS query in Elasticsearch.

Little curious why since the SQL is still passed to API and it has limitations but this is working.

 GET /_sql?format=txt
{
  "query": """
    SELECT agent.version FROM "metricbeat-8.3.1" WHERE agent.name LIKE '%file%' LIMIT 5
  """
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.