# Removing results from same domain in search query result

**URL:** <https://discuss.elastic.co/t/removing-results-from-same-domain-in-search-query-result/12445>\
**Category:** Elasticsearch\
**Created:** [June 17, 2013, 11:33am UTC](https://discuss.elastic.co/t/removing-results-from-same-domain-in-search-query-result/12445 "2013-06-17T11:33:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devashish\_Tyagi](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@Devashish\_Tyagi](https://discuss.elastic.co/u/Devashish_Tyagi)\
**Post date:** [June 17, 2013, 11:33am UTC](https://discuss.elastic.co/t/removing-results-from-same-domain-in-search-query-result/12445/1 "2013-06-17T11:33:45Z")

</div>

I have an index containing around 1 million HTML documents. The index  
mapping has following fields

1. _file_ _:_ Holding the actual html document
2. \*url : \*Holds the source url of the html document
3. \*meta-data : \*Some meta data associated with the document

I want to do the following :

1. Query the index for a result set of size 100.
2. Prune the result set so that it contains at most 2 results from a  
particular domain.

For the pruning part, I was wondering whether I can use script filter to  
perform this function. Is it possible to do this using script filter ? If  
yes then how ? Is there any other option to do what I want to do ?

Thanks!

- 
  - 

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [June 18, 2013, 6:32pm UTC](https://discuss.elastic.co/t/removing-results-from-same-domain-in-search-query-result/12445/2 "2013-06-18T18:32:27Z")

</div>

My first thought would be a custom facet/collector, but that would require  
a fair amount of code. Perhaps Igor's facet script could help? I have never  
used it.

> **[GitHub - imotov/elasticsearch-facet-script: Fully Scriptable Facets for...](https://github.com/imotov/elasticsearch-facet-script)**
>
> Fully Scriptable Facets for ElasticSearch. Contribute to imotov/elasticsearch-facet-script development by creating an account on GitHub.

--  
Ivan

On Mon, Jun 17, 2013 at 4:33 AM, Devashish Tyagi  
[devashishrocker@gmail.com](mailto:devashishrocker@gmail.com)wrote:

> I have an index containing around 1 million HTML documents. The index  
> mapping has following fields
> 
> 1. _file_ _:_ Holding the actual html document
> 2. \*url : \*Holds the source url of the html document
> 3. \*meta-data : \*Some meta data associated with the document
> 
> I want to do the following :
> 
> 1. Query the index for a result set of size 100.
> 2. Prune the result set so that it contains at most 2 results from a  
> particular domain.
> 
> For the pruning part, I was wondering whether I can use script filter to  
> perform this function. Is it possible to do this using script filter ? If  
> yes then how ? Is there any other option to do what I want to do ?
> 
> Thanks!
> 
> - 
> - 
> 
> --  
> 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).

--  
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:30am UTC](https://discuss.elastic.co/t/removing-results-from-same-domain-in-search-query-result/12445/3 "2017-07-06T02:30:31Z")

</div>

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


