# Search question

**URL:** <https://discuss.elastic.co/t/search-question/8592>\
**Category:** Elasticsearch\
**Created:** [August 1, 2012, 10:58am UTC](https://discuss.elastic.co/t/search-question/8592 "2012-08-01T10:58:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticuser\_2](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@elasticuser\_2](https://discuss.elastic.co/u/elasticuser_2)\
**Post date:** [August 1, 2012, 10:58am UTC](https://discuss.elastic.co/t/search-question/8592/1 "2012-08-01T10:58:29Z")

</div>

Hello,

In this example :

$ curl -XPUT '[http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1)' -d '{  
"name" : "dir1",  
"hash" : "11a3e229084349bc25d97e29393ced1d"  
}'  
$ curl -XPUT '[http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)' -d '{  
"name" : "dir2",  
"hash" : "61a1d3d61d5c3f134006f9302b1e4775"  
}'  
$ curl -XPUT '[http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)' -d '{  
"name" : "test1",  
"hash" : "3e7705498e8be60520841409ebc69bc1"  
}'

$ curl -XPUT '[http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)' -d '{  
"name" : "file1",  
"hash" : "11a3e229084349bc25d97e29393ced1d"  
}'  
$ curl -XPUT '[http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)' -d '{  
"name" : "filte2",  
"hash" : "62108f16c7d809f960d745b446d91a08"  
}'

How I can search into dir type all dir where "name=dir\*" and hash is into  
file type ?

Thanks.

---

<div class="post-metadata">

**Author:** ![elasticuser\_2](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@elasticuser\_2](https://discuss.elastic.co/u/elasticuser_2)\
**Post date:** [August 6, 2012, 9:48am UTC](https://discuss.elastic.co/t/search-question/8592/2 "2012-08-06T09:48:12Z")

</div>

Hello,

Someone has an idea ?

Thanks.

On Wednesday, August 1, 2012 12:58:29 PM UTC+2, elasticuser wrote:

> Hello,
> 
> In this example :
> 
> $ curl -XPUT '[http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1)' -d '{  
> "name" : "dir1",  
> "hash" : "11a3e229084349bc25d97e29393ced1d"  
> }'  
> $ curl -XPUT '[http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)' -d '{  
> "name" : "dir2",  
> "hash" : "61a1d3d61d5c3f134006f9302b1e4775"  
> }'  
> $ curl -XPUT '[http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)' -d '{  
> "name" : "test1",  
> "hash" : "3e7705498e8be60520841409ebc69bc1"  
> }'
> 
> $ curl -XPUT '[http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)' -d '{  
> "name" : "file1",  
> "hash" : "11a3e229084349bc25d97e29393ced1d"  
> }'  
> $ curl -XPUT '[http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)' -d '{  
> "name" : "filte2",  
> "hash" : "62108f16c7d809f960d745b446d91a08"  
> }'
> 
> How I can search into dir type all dir where "name=dir\*" and hash is into  
> file type ?
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 6, 2012, 12:43pm UTC](https://discuss.elastic.co/t/search-question/8592/3 "2012-08-06T12:43:25Z")

</div>

What I would probably do is to index documents in another way:

{  
"name" : "file1",  
"dirname" : "dir1"  
}

Then, it's easy to search for a file.

If it doesn't fit to your needs, then have a look at nested or parent/child  
concepts. I don't use it myself so I can't help you more than that here.

What is exactly your use case?

HTH  
David.

Le 6 août 2012 à 11:48, elasticuser [merik2004-elastic@yahoo.fr](mailto:merik2004-elastic@yahoo.fr) a écrit :

> Hello,
> 
> Someone has an idea ?
> 
> Thanks.
> 
> On Wednesday, August 1, 2012 12:58:29 PM UTC+2, elasticuser wrote:
> 
> > > Hello,
> > 
> > In this example :
> > 
> > $ curl -XPUT ' [http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1)' -d '{  
> > "name" : "dir1",  
> > "hash" : "11a3e229084349bc25d97e29393ced1d"  
> > }'  
> > $ curl -XPUT ' [http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1)  
> > [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)' -d '{  
> > "name" : "dir2",  
> > "hash" : "61a1d3d61d5c3f134006f9302b1e4775"  
> > }'  
> > $ curl -XPUT ' [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)  
> > [http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)' -d '{  
> > "name" : "test1",  
> > "hash" : "3e7705498e8be60520841409ebc69bc1"  
> > }'
> > 
> > $ curl -XPUT ' [http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)  
> > [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)' -d '{  
> > "name" : "file1",  
> > "hash" : "11a3e229084349bc25d97e29393ced1d"  
> > }'  
> > $ curl -XPUT ' [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)  
> > [http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)' -d '{  
> > "name" : "filte2",  
> > "hash" : "62108f16c7d809f960d745b446d91a08"  
> > }'
> > 
> > How I can search into dir type all dir where "name=dir\*" and hash is into  
> > file type ?
> > 
> > Thanks.
> > 
> > ```
> > <http://localhost:9200/test/file/2>
> > 
> > ```
> > 
> > >

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

---

<div class="post-metadata">

**Author:** ![elasticuser\_2](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@elasticuser\_2](https://discuss.elastic.co/u/elasticuser_2)\
**Post date:** [August 6, 2012, 1:35pm UTC](https://discuss.elastic.co/t/search-question/8592/4 "2012-08-06T13:35:39Z")

</div>

Hello David,

Thanks for your answer.

I would like to do the same thing that a join request :

select \* from dir,file where dir.name like 'dir%' and dir.hash = file.hash;

I will see the parent/child concepts.

Thanks.

On Monday, August 6, 2012 2:43:25 PM UTC+2, David Pilato wrote:

> What I would probably do is to index documents in another way:
> 
> {  
> "name" : "file1",  
> "dirname" : "dir1"  
> }
> 
> Then, it's easy to search for a file.
> 
> If it doesn't fit to your needs, then have a look at nested or  
> parent/child concepts. I don't use it myself so I can't help you more than  
> that here.
> 
> What is exactly your use case?
> 
> HTH
> 
> David.
> 
> Hello,
> 
> Someone has an idea ?
> 
> Thanks.
> 
> On Wednesday, August 1, 2012 12:58:29 PM UTC+2, elasticuser wrote:
> 
> Hello,
> 
> In this example :
> 
> $ curl -XPUT ' [http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1)' -d '{  
> "name" : "dir1",  
> "hash" : "11a3e229084349bc25d97e29393ced1d"  
> }'  
> $ curl -XPUT ' [http://localhost:9200/test/dir/1](http://localhost:9200/test/dir/1) [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)'  
> -d '{  
> "name" : "dir2",  
> "hash" : "61a1d3d61d5c3f134006f9302b1e4775"  
> }'  
> $ curl -XPUT ' [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2) [http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)'  
> -d '{  
> "name" : "test1",  
> "hash" : "3e7705498e8be60520841409ebc69bc1"  
> }'
> 
> $ curl -XPUT ' [http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3) [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)'  
> -d '{  
> "name" : "file1",  
> "hash" : "11a3e229084349bc25d97e29393ced1d"  
> }'  
> $ curl -XPUT ' [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1) [http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)'  
> -d '{  
> "name" : "filte2",  
> "hash" : "62108f16c7d809f960d745b446d91a08"  
> }'
> 
> How I can search into dir type all dir where "name=dir\*" and hash is into  
> file type ?
> 
> Thanks.
> 
> [http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 6, 2012, 2:22pm UTC](https://discuss.elastic.co/t/search-question/8592/5 "2012-08-06T14:22:34Z")

</div>

Yes I understand that but IMHO you should keep in mind that you are now in a  
NoSQL world.  
That means that you should not think as before with SQL (relationnal) world.

So, it's best to persist your documents with full data not with relationship  
between documents.  
Or, if you _really_ need to, then have a look at parent/child.

My 2 cents  
David.

Le 6 août 2012 à 15:35, elasticuser [merik2004-elastic@yahoo.fr](mailto:merik2004-elastic@yahoo.fr) a écrit :

> Hello David,
> 
> Thanks for your answer.
> 
> I would like to do the same thing that a join request :
> 
> select \* from dir,file where dir.name like 'dir%' and dir.hash = file.hash;
> 
> I will see the parent/child concepts.
> 
> Thanks.
> 
> On Monday, August 6, 2012 2:43:25 PM UTC+2, David Pilato wrote:
> 
> > > What I would probably do is to index documents in another way:
> > 
> > {  
> > "name" : "file1",  
> > "dirname" : "dir1"  
> > }
> > 
> > Then, it's easy to search for a file.
> > 
> > If it doesn't fit to your needs, then have a look at nested or  
> > parent/child concepts. I don't use it myself so I can't help you more than  
> > that here.
> > 
> > What is exactly your use case?
> > 
> > HTH  
> > David.
> > 
> > ```
> > > > > Hello,
> > 
> > ```
> > 
> > > ```
> > > Someone has an idea ?
> > > 
> > > Thanks.
> > > 
> > > On Wednesday, August 1, 2012 12:58:29 PM UTC+2, elasticuser wrote:
> > > > > > > Hello,
> > > 
> > > ```
> > > 
> > > > ```
> > > > In this example :
> > > > 
> > > > $ curl -XPUT ' http://localhost:9200/test/dir/1' -d '{
> > > > "name" : "dir1",
> > > > "hash" : "11a3e229084349bc25d97e29393ced1d"
> > > > }'
> > > > $ curl -XPUT ' <http://localhost:9200/test/dir/1>
> > > > 
> > > > ```
> > > > 
> > > > [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)' -d '{  
> > > > "name" : "dir2",  
> > > > "hash" : "61a1d3d61d5c3f134006f9302b1e4775"  
> > > > }'  
> > > > $ curl -XPUT ' [http://localhost:9200/test/dir/2](http://localhost:9200/test/dir/2)  
> > > > [http://localhost:9200/test/dir/3](http://localhost:9200/test/dir/3)' -d '{  
> > > > "name" : "test1",  
> > > > "hash" : "3e7705498e8be60520841409ebc69bc1"  
> > > > }'
> > > > 
> > > > ```
> > > > $ curl -XPUT ' <http://localhost:9200/test/dir/3>
> > > > 
> > > > ```
> > > > 
> > > > [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)' -d '{  
> > > > "name" : "file1",  
> > > > "hash" : "11a3e229084349bc25d97e29393ced1d"  
> > > > }'  
> > > > $ curl -XPUT ' [http://localhost:9200/test/file/1](http://localhost:9200/test/file/1)  
> > > > [http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)' -d '{  
> > > > "name" : "filte2",  
> > > > "hash" : "62108f16c7d809f960d745b446d91a08"  
> > > > }'
> > > > 
> > > > ```
> > > > How I can search into dir type all dir where "name=dir*" and hash
> > > > 
> > > > ```
> > > > 
> > > > is into file type ?
> > > > 
> > > > ```
> > > > Thanks.
> > > > 
> > > > <http://localhost:9200/test/file/2>
> > > > > > > 
> > > > 
> > > > ```
> > > > 
> > > > >
> > 
> > --  
> > David Pilato  
> > [http://localhost:9200/test/file/2](http://localhost:9200/test/file/2)  
> > [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/) [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/) [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > >

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

---

<div class="post-metadata">

**Author:** ![elasticuser\_2](https://avatars.discourse-cdn.com/v4/letter/e/e480ec/32.png) [@elasticuser\_2](https://discuss.elastic.co/u/elasticuser_2)\
**Post date:** [August 6, 2012, 4:25pm UTC](https://discuss.elastic.co/t/search-question/8592/6 "2012-08-06T16:25:25Z")

</div>

OK, thanks for your help David.

---

<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, 3:17am UTC](https://discuss.elastic.co/t/search-question/8592/7 "2017-07-06T03:17:36Z")

</div>


