# How to select the correct use based on this mapping?

**URL:** <https://discuss.elastic.co/t/how-to-select-the-correct-use-based-on-this-mapping/11593>\
**Category:** Elasticsearch\
**Created:** [April 15, 2013, 6:08pm UTC](https://discuss.elastic.co/t/how-to-select-the-correct-use-based-on-this-mapping/11593 "2013-04-15T18:08:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_Bajka\_2](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Andy\_Bajka\_2](https://discuss.elastic.co/u/Andy_Bajka_2)\
**Post date:** [April 15, 2013, 6:08pm UTC](https://discuss.elastic.co/t/how-to-select-the-correct-use-based-on-this-mapping/11593/1 "2013-04-15T18:08:15Z")

</div>

Due to the way the mapping is setup by Xenforo, the user can be either a  
post-user or a thread-user and when I select user in my query, I get both  
when I only want the post-user.

Here is the mapping:

```
{
  "xenforo113" : {
    "post" : {
      "_source" : {
        "enabled" : false
      },
      "properties" : {
        "date" : {
          "type" : "long",
          "store" : "yes"
        },
        "discussion_id" : {
          "type" : "long",
          "store" : "yes"
        },
        "message" : {
          "type" : "string"
        },
        "node" : {
          "type" : "long"
        },
        "thread" : {
          "type" : "long"
        },
        "title" : {
          "type" : "string"
        },
        "user" : {
          "type" : "long",
          "store" : "yes"
        }
      }
    },
    "profile_post" : {
      "_source" : {
        "enabled" : false
      },
      "properties" : {
        "date" : {
          "type" : "long",
          "store" : "yes"
        },
        "discussion_id" : {
          "type" : "long",
          "store" : "yes"
        },
        "message" : {
          "type" : "string"
        },
        "title" : {
          "type" : "string"
        },
        "user" : {
          "type" : "long",
          "store" : "yes"
        }
      }
    },
    "thread" : {
      "_source" : {
        "enabled" : false
      },
      "properties" : {
        "date" : {
          "type" : "long",
          "store" : "yes"
        },
        "discussion_id" : {
          "type" : "long",
          "store" : "yes"
        },
        "message" : {
          "type" : "string"
        },
        "node" : {
          "type" : "long"
        },
        "thread" : {
          "type" : "long"
        },
        "title" : {
          "type" : "string"
        },
        "user" : {
          "type" : "long",
          "store" : "yes"
        }
      }
    }
  }
}

```

Here is the query:

"query": {  
"filtered": {  
"query": {  
"match\_all": {  
}  
},  
"filter": {  
"bool": {  
"must": {  
"term": {  
"user": "' . $user\_id . '"  
}  
},  
"must": {  
"term": {  
"node": "' . $node\_id . '"  
}  
},  
"must\_not": {  
"range": {  
"node": {  
"from": 100,  
"to": 100  
}  
}  
}  
}  
}  
}  
}

Is it possible to select in the "must" area that only post-user data is  
selected?

Thank you.

Andy

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:40am UTC](https://discuss.elastic.co/t/how-to-select-the-correct-use-based-on-this-mapping/11593/2 "2017-07-06T02:40:59Z")

</div>

Closed on July 6, 2017, 2:40am UTC


