# Search documents which contain a document

**URL:** <https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185>\
**Category:** Elasticsearch\
**Created:** [April 4, 2011, 9:21am UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185 "2011-04-04T09:21:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Duponchelle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_duponchelle/32/3246_2.png) [@Julien\_Duponchelle](https://discuss.elastic.co/u/Julien_Duponchelle)\
**Post date:** [April 4, 2011, 9:21am UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/1 "2011-04-04T09:21:19Z")

</div>

Hi,

I have the following problem.

I need to index books and publishers. I create two type of documents:

- publisher
- book

A publisher can publish a lot of book and a book can be publish by  
many publisher.

I need to be able to search a publisher by publisher name (ex:  
Penguin) or by book title (ex: Harry Potter) in the same text input.

If i search Penguin i want the publisher Penguin before publisher who  
publish books about penguins.

My first try was to push information about book in publisher  
documents, but that require two modify the publisher document each  
time we add a book but this slow the indexation because we can't index  
two books from the same publisher at the same time.

Have you a better solution for that problem?

Thanks by advance

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [April 4, 2011, 10:56am UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/2 "2011-04-04T10:56:59Z")

</div>

Hi,

I think the most naive solution could be giving the publisher field a high  
boost during indexing?

Regards,  
Lukas

On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
[julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:

> Hi,
> 
> I have the following problem.
> 
> I need to index books and publishers. I create two type of documents:
> 
> - publisher
> - book
> 
> A publisher can publish a lot of book and a book can be publish by  
> many publisher.
> 
> I need to be able to search a publisher by publisher name (ex:  
> Penguin) or by book title (ex: Harry Potter) in the same text input.
> 
> If i search Penguin i want the publisher Penguin before publisher who  
> publish books about penguins.
> 
> My first try was to push information about book in publisher  
> documents, but that require two modify the publisher document each  
> time we add a book but this slow the indexation because we can't index  
> two books from the same publisher at the same time.
> 
> Have you a better solution for that problem?
> 
> Thanks by advance

---

<div class="post-metadata">

**Author:** ![Julien\_Duponchelle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_duponchelle/32/3246_2.png) [@Julien\_Duponchelle](https://discuss.elastic.co/u/Julien_Duponchelle)\
**Post date:** [April 4, 2011, 11:19am UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/3 "2011-04-04T11:19:29Z")

</div>

Yes, but can i avoid to push book information in publisher document?

On Mon, Apr 4, 2011 at 12:56, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> Hi,
> 
> I think the most naive solution could be giving the publisher field a high  
> boost during indexing?
> 
> Regards,  
> Lukas
> 
> On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
> [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> 
> > Hi,
> > 
> > I have the following problem.
> > 
> > I need to index books and publishers. I create two type of documents:
> > 
> > - publisher
> > - book
> > 
> > A publisher can publish a lot of book and a book can be publish by  
> > many publisher.
> > 
> > I need to be able to search a publisher by publisher name (ex:  
> > Penguin) or by book title (ex: Harry Potter) in the same text input.
> > 
> > If i search Penguin i want the publisher Penguin before publisher who  
> > publish books about penguins.
> > 
> > My first try was to push information about book in publisher  
> > documents, but that require two modify the publisher document each  
> > time we add a book but this slow the indexation because we can't index  
> > two books from the same publisher at the same time.
> > 
> > Have you a better solution for that problem?
> > 
> > Thanks by advance

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [April 4, 2011, 12:05pm UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/4 "2011-04-04T12:05:14Z")

</div>

Hi,

How about using terms facet?  
May be if you can elaborate more on how you want to present the results to  
the users.

Regards,  
Lukas

On Mon, Apr 4, 2011 at 1:19 PM, Julien Duponchelle \<  
[julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:

> Yes, but can i avoid to push book information in publisher document?
> 
> On Mon, Apr 4, 2011 at 12:56, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:
> 
> > Hi,
> > 
> > I think the most naive solution could be giving the publisher field a high  
> > boost during indexing?
> > 
> > Regards,  
> > Lukas
> > 
> > On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
> > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > 
> > > Hi,
> > > 
> > > I have the following problem.
> > > 
> > > I need to index books and publishers. I create two type of documents:
> > > 
> > > - publisher
> > > - book
> > > 
> > > A publisher can publish a lot of book and a book can be publish by  
> > > many publisher.
> > > 
> > > I need to be able to search a publisher by publisher name (ex:  
> > > Penguin) or by book title (ex: Harry Potter) in the same text input.
> > > 
> > > If i search Penguin i want the publisher Penguin before publisher who  
> > > publish books about penguins.
> > > 
> > > My first try was to push information about book in publisher  
> > > documents, but that require two modify the publisher document each  
> > > time we add a book but this slow the indexation because we can't index  
> > > two books from the same publisher at the same time.
> > > 
> > > Have you a better solution for that problem?
> > > 
> > > Thanks by advance

---

<div class="post-metadata">

**Author:** ![Julien\_Duponchelle\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_duponchelle_2/32/3194_2.png) [@Julien\_Duponchelle\_2](https://discuss.elastic.co/u/Julien_Duponchelle_2)\
**Post date:** [April 4, 2011, 12:18pm UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/5 "2011-04-04T12:18:44Z")

</div>

Hi,

I display only the publisher name. The problem is my users type in the same  
field book name or publisher name in order to found a publisher. I can make  
double search on publisher and books and merge the two search but search on  
books sometimes return 100 times the same publisher as the first result.

Thanks for your help

On Mon, Apr 4, 2011 at 14:05, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> Hi,
> 
> How about using terms facet?  
> May be if you can elaborate more on how you want to present the results to  
> the users.
> 
> Regards,  
> Lukas
> 
> On Mon, Apr 4, 2011 at 1:19 PM, Julien Duponchelle \<  
> [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> 
> > Yes, but can i avoid to push book information in publisher document?
> > 
> > On Mon, Apr 4, 2011 at 12:56, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > I think the most naive solution could be giving the publisher field a  
> > > high boost during indexing?
> > > 
> > > Regards,  
> > > Lukas
> > > 
> > > On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
> > > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I have the following problem.
> > > > 
> > > > I need to index books and publishers. I create two type of documents:
> > > > 
> > > > - publisher
> > > > - book
> > > > 
> > > > A publisher can publish a lot of book and a book can be publish by  
> > > > many publisher.
> > > > 
> > > > I need to be able to search a publisher by publisher name (ex:  
> > > > Penguin) or by book title (ex: Harry Potter) in the same text input.
> > > > 
> > > > If i search Penguin i want the publisher Penguin before publisher who  
> > > > publish books about penguins.
> > > > 
> > > > My first try was to push information about book in publisher  
> > > > documents, but that require two modify the publisher document each  
> > > > time we add a book but this slow the indexation because we can't index  
> > > > two books from the same publisher at the same time.
> > > > 
> > > > Have you a better solution for that problem?
> > > > 
> > > > Thanks by advance

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [April 4, 2011, 12:32pm UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/6 "2011-04-04T12:32:04Z")

</div>

So the terms facet could be an ideal solution for you?  
Let's have a query that has two terms facets, one for the publisher and the  
second for book name and then combine these results on the client side  
displaying publishers first. Would this help?

Regards,  
Lukas

On Mon, Apr 4, 2011 at 2:18 PM, Julien Duponchelle  
[julien@duponchelle.info](mailto:julien@duponchelle.info)wrote:

> Hi,
> 
> I display only the publisher name. The problem is my users type in the same  
> field book name or publisher name in order to found a publisher. I can make  
> double search on publisher and books and merge the two search but search on  
> books sometimes return 100 times the same publisher as the first result.
> 
> Thanks for your help
> 
> On Mon, Apr 4, 2011 at 14:05, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:
> 
> > Hi,
> > 
> > How about using terms facet?  
> > May be if you can elaborate more on how you want to present the results to  
> > the users.
> > 
> > Regards,  
> > Lukas
> > 
> > On Mon, Apr 4, 2011 at 1:19 PM, Julien Duponchelle \<  
> > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > 
> > > Yes, but can i avoid to push book information in publisher document?
> > > 
> > > On Mon, Apr 4, 2011 at 12:56, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I think the most naive solution could be giving the publisher field a  
> > > > high boost during indexing?
> > > > 
> > > > Regards,  
> > > > Lukas
> > > > 
> > > > On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
> > > > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > > > 
> > > > > Hi,
> > > > > 
> > > > > I have the following problem.
> > > > > 
> > > > > I need to index books and publishers. I create two type of documents:
> > > > > 
> > > > > - publisher
> > > > > - book
> > > > > 
> > > > > A publisher can publish a lot of book and a book can be publish by  
> > > > > many publisher.
> > > > > 
> > > > > I need to be able to search a publisher by publisher name (ex:  
> > > > > Penguin) or by book title (ex: Harry Potter) in the same text input.
> > > > > 
> > > > > If i search Penguin i want the publisher Penguin before publisher who  
> > > > > publish books about penguins.
> > > > > 
> > > > > My first try was to push information about book in publisher  
> > > > > documents, but that require two modify the publisher document each  
> > > > > time we add a book but this slow the indexation because we can't index  
> > > > > two books from the same publisher at the same time.
> > > > > 
> > > > > Have you a better solution for that problem?
> > > > > 
> > > > > Thanks by advance

---

<div class="post-metadata">

**Author:** ![Julien\_Duponchelle\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julien_duponchelle_2/32/3194_2.png) [@Julien\_Duponchelle\_2](https://discuss.elastic.co/u/Julien_Duponchelle_2)\
**Post date:** [April 4, 2011, 12:37pm UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/7 "2011-04-04T12:37:33Z")

</div>

That's sound good i will give it a try.

Thanks

On Mon, Apr 4, 2011 at 14:32, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> So the terms facet could be an ideal solution for you?  
> Let's have a query that has two terms facets, one for the publisher and the  
> second for book name and then combine these results on the client side  
> displaying publishers first. Would this help?
> 
> Regards,  
> Lukas
> 
> On Mon, Apr 4, 2011 at 2:18 PM, Julien Duponchelle \<  
> julien@duponchelle.info\> wrote:
> 
> > Hi,
> > 
> > I display only the publisher name. The problem is my users type in the  
> > same field book name or publisher name in order to found a publisher. I can  
> > make double search on publisher and books and merge the two search but  
> > search on books sometimes return 100 times the same publisher as the first  
> > result.
> > 
> > Thanks for your help
> > 
> > On Mon, Apr 4, 2011 at 14:05, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > How about using terms facet?  
> > > May be if you can elaborate more on how you want to present the results  
> > > to the users.
> > > 
> > > Regards,  
> > > Lukas
> > > 
> > > On Mon, Apr 4, 2011 at 1:19 PM, Julien Duponchelle \<  
> > > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > > 
> > > > Yes, but can i avoid to push book information in publisher document?
> > > > 
> > > > On Mon, Apr 4, 2011 at 12:56, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com)wrote:
> > > > 
> > > > > Hi,
> > > > > 
> > > > > I think the most naive solution could be giving the publisher field a  
> > > > > high boost during indexing?
> > > > > 
> > > > > Regards,  
> > > > > Lukas
> > > > > 
> > > > > On Mon, Apr 4, 2011 at 11:21 AM, Julien Duponchelle \<  
> > > > > [julien.duponchelle@gmail.com](mailto:julien.duponchelle@gmail.com)\> wrote:
> > > > > 
> > > > > > Hi,
> > > > > > 
> > > > > > I have the following problem.
> > > > > > 
> > > > > > I need to index books and publishers. I create two type of documents:
> > > > > > 
> > > > > > - publisher
> > > > > > - book
> > > > > > 
> > > > > > A publisher can publish a lot of book and a book can be publish by  
> > > > > > many publisher.
> > > > > > 
> > > > > > I need to be able to search a publisher by publisher name (ex:  
> > > > > > Penguin) or by book title (ex: Harry Potter) in the same text input.
> > > > > > 
> > > > > > If i search Penguin i want the publisher Penguin before publisher who  
> > > > > > publish books about penguins.
> > > > > > 
> > > > > > My first try was to push information about book in publisher  
> > > > > > documents, but that require two modify the publisher document each  
> > > > > > time we add a book but this slow the indexation because we can't index  
> > > > > > two books from the same publisher at the same time.
> > > > > > 
> > > > > > Have you a better solution for that problem?
> > > > > > 
> > > > > > Thanks by advance

---

<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, 4:08am UTC](https://discuss.elastic.co/t/search-documents-which-contain-a-document/4185/8 "2017-07-06T04:08:56Z")

</div>


