# IndexOutOfBoundsException when specifying type \[Post from Found\]

**URL:** <https://discuss.elastic.co/t/indexoutofboundsexception-when-specifying-type-post-from-found/32898>\
**Category:** Elasticsearch\
**Created:** [October 24, 2015, 3:24am UTC](https://discuss.elastic.co/t/indexoutofboundsexception-when-specifying-type-post-from-found/32898 "2015-10-24T03:24:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikthered](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@erikthered](https://discuss.elastic.co/u/erikthered)\
**Post date:** [October 24, 2015, 3:24am UTC](https://discuss.elastic.co/t/indexoutofboundsexception-when-specifying-type-post-from-found/32898/1 "2015-10-24T03:24:58Z")

</div>

Continuing the discussion from [IndexOutOfBoundsException when specifying type](https://discuss.elastic.co/t/indexoutofboundsexception-when-specifying-type/32888):

> [@On another topic](https://discuss.elastic.co/t/32888/1):
>
> I have a query that is failing when I specify a type (e.g. `localhost:9200/development/entity_analytics`) but not when I just search on `localhost:9200/development`
> 
> I get this error:  
> `Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[ElasticsearchParseException[failed to parse / load source]; nested: IndexOutOfBoundsException[docID must be >= 0 and < maxDoc=80 (got docID=6284)]; ]; "`
> 
> This only happens when I have two scripts in my query, and aggregation and TF calculation, like so:
> 
> ```
> {
> "query": {
> "filtered": {
> "filter": {
> "bool": {
> "must": [
> {
> "has_parent": {
> "type": "profile_entity_relationship",
> "filter": {
> "bool": {
> "must": [
> {
> "term": {
> "profile_id": 12
> }
> },
> {
> "bool": {
> "must": [
> {
> "script": {
> "script": "(_index['title'][term].tf() + _index['content'][term].tf()) >= frequency",
> "params": {
> "term": "facebook",
> "frequency": 1
> }
> }
> }
> ]
> }
> }
> ]
> }
> }
> }
> }
> ]
> }
> }
> }
> },
> "aggs": {
> "revenue": {
> "sum": {
> "script": "Map map = new HashMap(); for(field in ['total_goals','total_events']){if(_source.containsKey(field)){for(e in _source[field]){ map.put(field+e.name, e.value.intValue());}}};(map.containsKey('total_eventsevent1') ? map.get('total_eventsevent1') * 500 : 0) "
> }
> }
> },
> "size": 0
> }
> 
> ```

---

<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:42pm UTC](https://discuss.elastic.co/t/indexoutofboundsexception-when-specifying-type-post-from-found/32898/2 "2017-07-05T23:42:48Z")

</div>

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


