# Searching across all fields in all types

**URL:** <https://discuss.elastic.co/t/searching-across-all-fields-in-all-types/2841>\
**Category:** Elasticsearch\
**Created:** [March 9, 2010, 1:30pm UTC](https://discuss.elastic.co/t/searching-across-all-fields-in-all-types/2841 "2010-03-09T13:30:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 9, 2010, 1:30pm UTC](https://discuss.elastic.co/t/searching-across-all-fields-in-all-types/2841/1 "2010-03-09T13:30:23Z")

</div>

Hiya

Let's say I have 3 types:

- user:
  - id
  - name
  - email

- blog\_post:
  - id
  - title
  - text

- comment:
  - id
  - title
  - text
  - blog\_post\_id

Searching for keywords is easy - I can search across types  
'blog\_post,comment' and fields: ["text","title"]

But I want an admin search that will search across all types, matching  
against any field in any type, (eg the admin searches for an ID, or an  
email address)

Is there a way to specify: "search across all fields for all object  
types", or do I have to specify the fields to search? What if I specify  
'email' as one of the fields, but 'blog\_post' doesn't have an 'email'  
field?

Or should I add another common field to all objects eg "keywords" which  
would contain all the keywords for all the other fields?

thanks

Clint

--  
Web Announcements Limited is a company registered in England and Wales,  
with company number 05608868, with registered address at 10 Arvon Road,  
London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 9, 2010, 1:47pm UTC](https://discuss.elastic.co/t/searching-across-all-fields-in-all-types/2841/2 "2010-03-09T13:47:42Z")

</div>

Hi,

You can certainly add fields (even ones that only exists on certain  
types) as fields in the queryString for example to search across all types.  
You will need, today, to add those fields yourself and do the search, no  
worries if some only exists in certain types.

I do plan to try and address this very common scenario. For example, in  
Compass (my other search project) there is a concept of an "all" field, that  
simply held all the fields content (thus increasing, though not by much  
thanks to the inverted index model) the index, but having the ability to  
search on the all field and thus basically searching on everything. The  
problem is that in Lucene 3.0 its a bit difficult to do what I did in  
Compass (it still uses Lucene 2.4). I do plan to see how this can be added  
though one way or (hack)nother.

-shay.banon

On Tue, Mar 9, 2010 at 3:30 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Hiya
> 
> Let's say I have 3 types:
> 
> - user:
> - id
> - name
> - email
> 
> - blog\_post:
> - id
> - title
> - text
> 
> - comment:
> - id
> - title
> - text
> - blog\_post\_id
> 
> Searching for keywords is easy - I can search across types  
> 'blog\_post,comment' and fields: ["text","title"]
> 
> But I want an admin search that will search across all types, matching  
> against any field in any type, (eg the admin searches for an ID, or an  
> email address)
> 
> Is there a way to specify: "search across all fields for all object  
> types", or do I have to specify the fields to search? What if I specify  
> 'email' as one of the fields, but 'blog\_post' doesn't have an 'email'  
> field?
> 
> Or should I add another common field to all objects eg "keywords" which  
> would contain all the keywords for all the other fields?
> 
> thanks
> 
> Clint
> 
> --  
> Web Announcements Limited is a company registered in England and Wales,  
> with company number 05608868, with registered address at 10 Arvon Road,  
> London, N5 1PR.

---

<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:25am UTC](https://discuss.elastic.co/t/searching-across-all-fields-in-all-types/2841/3 "2017-07-06T04:25:25Z")

</div>

Closed on July 6, 2017, 4:25am UTC


