Filtered Percolator Queries

Im trying to make suggestions to users based on several factors:

•Suggestions MUST only be students from the same college
•Suggestions MUST match at least one other field
Here is how I am currently doing it , but this does not seem right or efficent considering most of these fields are bool's .....if the colleges dont line up why bother even doing that query ?

 POST /interests_percolator/UNIQUE_INTERESTS/_percolate/
{ 
  "doc":{ 
    "message":"Bring it eminem"
  }
}


DELETE  discovery


PUT discovery
{
  "mappings": {
    "user": {
      "properties": {
        "hashtag_bio": {
          "type": "string"
        },
        "college": {
            "type": "string"
        },
        "college_class": {
            "type": "string"
        }
      }
    }
  }
}

PUT /discovery/.percolator/1
{
  "query": {
    "bool": {
    "must": [
        { "match": { "college":{
            "query" : "Oakland University",
            "type" : "phrase"
        }}}
    ],
      "should": [
        { "match": { "hashtag_bio": "#poznasty"   }},
        { "match": { "college_class": "BIO_310"}},
        { "match": { "college_class": "WRT_100"}}
      ],
      "minimum_should_match": 1 
    }
  }
}
PUT /discovery/.percolator/2
{
  "query": {
    "bool": {
    "must": [
        { "match": { "college":{
            "query" : "Oakland University",
            "type" : "phrase"
        }}}
    ],
      "should": [
        { "match": { "hashtag_bio": "#Chipotle"}}
      ],
      "minimum_should_match": 1 
    }
  }
}
PUT /discovery/.percolator/3
{
  "query": {
    "bool": {
    "must": [
        { "match": { "college":{
            "query" : "Oakland University",
            "type" : "phrase"
        }}}
    ],
      "should": [
        { "match": { "college_class": "ART_400"}}
      ],
      "minimum_should_match": 1 
    }
  }
}

POST /discovery/user/_percolate/
{ 
  "doc":{ 
    "hashtag_bio":"#Chipotle",
    "college":"Oakland University"
   
  }
}

You may be able to move the college part to a metadata of the percolator item rather than in the query.

e.g

PUT /discovery/.percolator/1
{
  "query": {
    "bool": {
      "should": [
        { "match": { "hashtag_bio": "#poznasty"   }},
        { "match": { "college_class": "BIO_310"}},
        { "match": { "college_class": "WRT_100"}}
      ],
      "minimum_should_match": 1 
    }
  },
 "college":"Oakland University"
}

Then, when you call _percolate, something like:

POST /discovery/user/_percolate/
{ 
  "doc":{ 
    "hashtag_bio":"#Chipotle"
  },
  "filter": {
     "term": { "college": "Oakland University" }
  }
}

Hope this helps. For more information, check out https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_filtering_executed_queries

Sarwar