Search on the same field multiple times with different filters and intersect the results

Hi . I'm working on a project that records in my index have dynamic values . I mean I have a field named fieldvalue that can be a date or a text or a number and every record is piece of data from each user . The reason why used this because users have dynamic fields and save dynamic data into multiple forms . It's a formbuilder project so every field is dynamic.
I have multiple search filters and i want to find users that match those filters like text filter or date filter or number filter . filters are dynamic too . I want to know is there a way that I find users that match filters by search the same field (filedvalue in my index) in elastic. data is like below:

 {
        "_index" : "fieldvaluedata",
        "_type" : "_doc",
        "_id" : "118",
        "_score" : 1.0,
        "_source" : {
          "id" : 118,
          "userid" : 8,
          "userFormsId" : 195163,
          "recordId" : 64213,
          "formId" : 41,
          "fieldid" : 124,
          "fieldtype" : 10,
          "fieldName" : "field_2",
          "fieldvalue" : "May  8 2017  1:45PM",
          "createdate" : "2017-07-15T00:00:00"
        }
      },
      {
        "_index" : "fieldvaluedata",
        "_type" : "_doc",
        "_id" : "119",
        "_score" : 1.0,
        "_source" : {
          "id" : 119,
          "userid" : 8,
          "userFormsId" : 195163,
          "recordId" : 64213,
          "formId" : 41,
          "fieldid" : 123,
          "fieldtype" : 0,
          "fieldName" : "field_1",
          "fieldvalue" : "",
          "createdate" : "2017-07-15T00:00:00"
        }
      },
      {
        "_index" : "fieldvaluedata",
        "_type" : "_doc",
        "_id" : "120",
        "_score" : 1.0,
        "_source" : {
          "id" : 120,
          "userid" : 8,
          "userFormsId" : 195163,
          "recordId" : 64213,
          "formId" : 41,
          "fieldid" : 125,
          "fieldtype" : 0,
          "fieldName" : "field_3",
          "fieldvalue" : "باشگاه مشتریان شهرداری",
          "createdate" : "2017-07-15T00:00:00"
        }
      }

my search is like filter users that field value containts " some text" and field value is lower than 20 (for age) and date filter like lower than 2020-02-10 and send back users that match these conditions.

I found the solution using filters aggregation I could search on same field multiple times and then intersect the results I could get what I wanted.

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