Search multiple values for a single field

Hii.. All , I am pretty new in elk search, I want to find out multiple values for a single field (diseases:” fever,covid_19”) with in a must with wildcard condition

here the data is like this
Diseases: “fever, headache, cold cough”
Diseases:” fever, infection”
Diseases:” fever,covid_19”

I have tried like this

{ 'query': {'bool': {'filter': [{'bool': {'must': [{'wildcard': {'diseases': 'fev*'}}, {'wildcard': {'diseases': 'cov*'}}, {'range': {'visit_created_dttm': {'gte': '2020-06-23', 'lte': '2020-12-30'}}}}}

but it fails to recognize perticular values ..
please help me..how can i find out the the perticular values.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

we want to find out multiple comma sepated values for a single field
for example
field=value1,value2
diesease = fever,head ache

please suggest me the search query for this..

1.diesease = fever,body pain,head ache
2.diesease = fever,cold cough,
3.diesease =blood preesure, fever,stomach pain
4.diesease =head ache, fever,stomach pain

we have to sort out those patient whose have fever and head ache both
as the above example
we should show only 2 records
1.diesease = fever,body pain,head ache
4.diesease =head ache, fever,stomach pain

please suggest me the search query for this..

Please provide a script we can start from.

I am trying the search script like this

GET /patient_history/_search
{"query": {"bool": {"filter": [{"bool": {"must": [{"wildcard": {"diseases": "fever,head ache"}}]}}]}}}

When I run it it says that the index does not exist.

Yes.. I think you have to insert some dummy above data by creating an index.. as any name like patient_history..
So that you can fetch that..
Hope you understood our requirement..

But what if you share with us this dummy data?

Again, have a look at the example.

hits": {
        "total": {
            "value": 4,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "patient_history",
                "_type": "_doc",
                "_id": "1",
                "_score": 1.0,
                "_source": {
                    "diesease": "fever,body pain,head ache"}, {
                "_index": "patient_history",
                "_type": "_doc",
                "_id": "2",
                "_score": 1.0,
                "_source": {
                    "diesease": "fever,cold cough"},
 {
                "_index": "patient_history",
                "_type": "_doc",
                "_id": "3",
                "_score": 1.0,
                "_source": {
                    "diesease": "blood preesure, fever,stomach pain"}, 
{
                "_index": "patient_history",
                "_type": "_doc",
                "_id": "4",
                "_score": 1.0,
                "_source": {
                    "diesease": "head ache, fever,stomach pain"}

1.diesease = "fever,body pain,head ache",
2.diesease = "fever,cold cough"
3.diesease ="blood preesure, fever,stomach pain"
4.diesease ="head ache, fever,stomach pain"

we want to split out multiple comma sepated values for a single field and sort out those patient whose have "fever" and "head ache" both
as the above example
we should show only 2 records
1.diesease = "fever,body pain,head ache"
4.diesease ="head ache, fever,stomach pain"

We are getting closer. Very cool.

Just to be sure that you understand what is expected, I'm going to copy and paste what a typical script is so you can copy/paste it your self and see how this can work. Note that this is coming from this post: About the Elasticsearch category

DELETE index
PUT index/_doc/1
{
  "foo": "bar"
}
GET index/_search
{
  "query": {
    "match": {
      "foo": "bar"
    }
  }
}
GET /patient_history/_search
{"query": {"bool": {"filter": [{"bool": {"must": [{"wildcard": {"diseases": "fever,head ache"}}]}}]}}}

Sorry, I am not getting the appropriate solution, please check the above details that I have asked.

Hope you will understand..

When I run it it says that the index does not exist.

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