Filter documents from search result

Hi,

i have some data on a index in Elasticsearch that it displayed as follow

"hits" : {
    "total" : {
      "value" : 7,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "3c1",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 3,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.702",
            "lon" : "71.32"
          },
          "joins_field" : {
            "name" : "phone_book",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "4c1",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 4,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.622",
            "lon" : "71.102"
          },
          "joins_field" : {
            "name" : "phone_book",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "5c1",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 5,
          "user_gender" : 0,
          "user_location" : {
            "lat" : "33.712",
            "lon" : "71.212"
          },
          "joins_field" : {
            "name" : "phone_book",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "6c1",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 6,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.122",
            "lon" : "71.112"
          },
          "joins_field" : {
            "name" : "phone_book",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "2c1",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 2,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.722",
            "lon" : "71.02"
          },
          "joins_field" : {
            "name" : "phone_book",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "1f2",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 2,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.722",
            "lon" : "71.02"
          },
          "joins_field" : {
            "name" : "followed",
            "parent" : "1"
          }
        }
      },
      {
        "_index" : "fayvo_contacts",
        "_type" : "_doc",
        "_id" : "1f3",
        "_score" : 1.0,
        "_routing" : "1",
        "_source" : {
          "user_id" : 3,
          "user_gender" : 1,
          "user_location" : {
            "lat" : "34.702",
            "lon" : "71.32"
          },
          "joins_field" : {
            "name" : "followed",
            "parent" : "1"
          }
        }
      }
    ]
  }

i want to exclude the documents from the search result for which user_id field is present in both followed and phone_book relation.
i only want the documents with user_id field only present in phone_book and not in followed
is there any way to achieve the result

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