# Elastic Percolator- Avoid returning the same result x2 to same user

**URL:** <https://discuss.elastic.co/t/elastic-percolator-avoid-returning-the-same-result-x2-to-same-user/28149>\
**Category:** Elasticsearch\
**Created:** [August 27, 2015, 1:46am UTC](https://discuss.elastic.co/t/elastic-percolator-avoid-returning-the-same-result-x2-to-same-user/28149 "2015-08-27T01:46:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fresh83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fresh83/32/1500_2.png) [@Fresh83](https://discuss.elastic.co/u/Fresh83)\
**Post date:** [August 27, 2015, 1:46am UTC](https://discuss.elastic.co/t/elastic-percolator-avoid-returning-the-same-result-x2-to-same-user/28149/1 "2015-08-27T01:46:04Z")

</div>

So ive created a Elastic Search percolator . How it works:

•Users sign up  
•User is required to add their college classes  
•User is asked to create a hashtag based bio of their interests Ex: #Chipotle#Boxing#MrRobot #FightClub #Drawing  
•User submits data - Our API analyzes the hashtag based bio , creates a array of all the hashtags in the bio and then creates a percolator that looks like this currently:

```
PUT /discovery/.percolator/3
{
  "query": {
    "bool": {
    "must": [
        { "match": { "college":{
            "query" : "Oakland University",
            "type" : "phrase"
        }}}
    ],
      "should": [
        { "match": { "college_class": "ART_400"}},
        { "match": { "college_class": "BIO_200"}},
        { "match": { "hashtag_bio": "#Boxing"}},
        { "match": { "hashtag_bio": "#MrRobot"}},
        { "match": { "hashtag_bio": "#FightClub"}},
        { "match": { "hashtag_bio": "#Running"}}
        
      ],
      "minimum_should_match": 1 
    }
  }
}

```

From there the user is taken into the app where we try to curate and suggest the best possible friend matches for them based on their hashtags and classes aka a query like this is made:

```
    POST /discovery/user/_percolate/
    { 
      "doc":{ 
    
        "hashtag_bio":"Hi my name is Chuck and I like #Chipotle #MrRobot and #fightClub",
        "college":"Oakland University"
       
      }
    }

**

```

## My question is: Is there a way to add the userID's of all the users that have already swiped on each of the users in my percolator to avoid showing repeats/enable chunked results?

```
EXAMPLE:  

    PUT /discovery/.percolator/3
    {
      "query": {
        "bool": {
        "must": [
            { "match": { "college":{
                "query" : "Oakland University",
                "type" : "phrase"
            }}}
        ],
          "should": [
            { "match": { "college_class": "ART_400"}},
            { "match": { "college_class": "BIO_200"}},
            { "match": { "hashtag_bio": "#Boxing"}},
            { "match": { "hashtag_bio": "#MrRobot"}},
            { "match": { "hashtag_bio": "#FightClub"}},
            { "match": { "hashtag_bio": "#Running"}}
            
          ],
          "minimum_should_match": 1,
          "must_not": [
            { "match": { "userID": "2"}},
            { "match": { "userID": "3"}},
            { "match": { userID": "4"}},
            { "match": { "userID": "5"}},
            { "match": { "userID": "6"}}
            
          ],
        }
      }
    }

```

Is using MUST\_NOT like this a efficient use if there were literally 100's or 1000's of userID's ? Is there a better way ?

---

<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 5, 2017, 11:53pm UTC](https://discuss.elastic.co/t/elastic-percolator-avoid-returning-the-same-result-x2-to-same-user/28149/2 "2017-07-05T23:53:38Z")

</div>

Closed on July 5, 2017, 11:53pm UTC


