How to select the correct use based on this mapping?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to select the correct use based on this mapping?

Andy Bajka-2
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.