# SearchException Constructor changed in 0.12.1? (were upgrading from 0.9.0)

**URL:** <https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575>\
**Category:** Elasticsearch\
**Created:** [November 15, 2010, 10:21pm UTC](https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575 "2010-11-15T22:21:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gideon\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gideon\_Kaplan](https://discuss.elastic.co/u/Gideon_Kaplan)\
**Post date:** [November 15, 2010, 10:21pm UTC](https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575/1 "2010-11-15T22:21:40Z")

</div>

Hi,  
We have groovy code like this  
public IndexType getType(Index index, String typeName) {  
if (index == null || typeName == null) {  
throw new SearchException("Index or type name provided was  
null!")  
}  
IndexType returnType = index.indexTypes.find {  
it.name == typeName  
}

```
    return returnType
}

```

But now getting stacktraces like  
2010-11-15 14:12:57,300 [http-8083-1] ERROR  
errors.GrailsExceptionResolver - Could not find matching constructor  
for: org.elasticsearch.search.SearchException(java.lang.String)  
groovy.lang.GroovyRuntimeException: Could not find matching  
constructor for:  
org.elasticsearch.search.SearchException(java.lang.String)  
at  
com.ticketfly.search.SearchQueryService.getType(SearchQueryService.groovy:  
283)  
at com.ticketfly.search.SearchQueryService$getType.call(Unknown  
Source)

Looking at the method sigs, its asking for a ShardTarget  
How does once quickly create a ShardTarget programmatically (from w/in  
the code)

package org.elasticsearch.search;

public static class SearchException extends  
org.elasticsearch.ElasticSearchException {  
private final org.elasticsearch.search.SearchShardTarget  
shardTarget;

```
public SearchException(org.elasticsearch.search.SearchShardTarget

```

shardTarget, java.lang.String msg) { /\* compiled code \*/ }

```
public SearchException(org.elasticsearch.search.SearchShardTarget

```

shardTarget, java.lang.String msg, java.lang.Throwable cause) { /\*  
compiled code \*/ }

```
public org.elasticsearch.search.SearchShardTarget shard() { /*

```

compiled code \*/ }  
}

Seems like ShardTarget asks for a few things  
public static class SearchShardTarget implements  
org.elasticsearch.common.io.stream.Streamable, java.io.Serializable{  
private java.lang.String nodeId;  
private java.lang.String index;  
private int shardId;

```
private SearchShardTarget() { /* compiled code */ }

public SearchShardTarget(java.lang.String nodeId, java.lang.String

```

index, int shardId) { /\* compiled code \*/ }

Thanks  
G

---

<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:** [November 15, 2010, 10:46pm UTC](https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575/2 "2010-11-15T22:46:41Z")

</div>

Hi,

Its an internal exception in elasticsearch in terms of construction. You  
can build it yourself (and put null/empty string in the node id), but its  
not guaranteed that it won't change in the future (the construction of it).

-shay.banon

On Tue, Nov 16, 2010 at 12:21 AM, Gideon Kaplan [gideonkaplan@gmail.com](mailto:gideonkaplan@gmail.com)wrote:

> Hi,  
> We have groovy code like this  
> public IndexType getType(Index index, String typeName) {  
> if (index == null || typeName == null) {  
> throw new SearchException("Index or type name provided was  
> null!")  
> }  
> IndexType returnType = index.indexTypes.find {  
> it.name == typeName  
> }
> 
> ```
> return returnType
> 
> ```
> 
> }
> 
> But now getting stacktraces like  
> 2010-11-15 14:12:57,300 [http-8083-1] ERROR  
> errors.GrailsExceptionResolver - Could not find matching constructor  
> for: org.elasticsearch.search.SearchException(java.lang.String)  
> groovy.lang.GroovyRuntimeException: Could not find matching  
> constructor for:  
> org.elasticsearch.search.SearchException(java.lang.String)  
> at  
> com.ticketfly.search.SearchQueryService.getType(SearchQueryService.groovy:  
> 283)  
> at com.ticketfly.search.SearchQueryService$getType.call(Unknown  
> Source)
> 
> Looking at the method sigs, its asking for a ShardTarget  
> How does once quickly create a ShardTarget programmatically (from w/in  
> the code)
> 
> package org.elasticsearch.search;
> 
> public static class SearchException extends  
> org.elasticsearch.ElasticSearchException {  
> private final org.elasticsearch.search.SearchShardTarget  
> shardTarget;
> 
> public SearchException(org.elasticsearch.search.SearchShardTarget  
> shardTarget, java.lang.String msg) { /\* compiled code \*/ }
> 
> public SearchException(org.elasticsearch.search.SearchShardTarget  
> shardTarget, java.lang.String msg, java.lang.Throwable cause) { /\*  
> compiled code \*/ }
> 
> public org.elasticsearch.search.SearchShardTarget shard() { /\*  
> compiled code \*/ }  
> }
> 
> Seems like ShardTarget asks for a few things  
> public static class SearchShardTarget implements  
> org.elasticsearch.common.io.stream.Streamable, java.io.Serializable{  
> private java.lang.String nodeId;  
> private java.lang.String index;  
> private int shardId;
> 
> private SearchShardTarget() { /\* compiled code \*/ }
> 
> public SearchShardTarget(java.lang.String nodeId, java.lang.String  
> index, int shardId) { /\* compiled code \*/ }
> 
> Thanks  
> G

---

<div class="post-metadata">

**Author:** ![Gideon\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Gideon\_Kaplan](https://discuss.elastic.co/u/Gideon_Kaplan)\
**Post date:** [November 16, 2010, 12:05am UTC](https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575/3 "2010-11-16T00:05:44Z")

</div>

Thanks Shay,  
I think were just going to roll our own search exception so were not  
as tightly coupled, but thanks for the response  
Gideon

On Nov 15, 2:46 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Hi,
> 
> Its an internal exception in elasticsearch in terms of construction. You  
> can build it yourself (and put null/empty string in the node id), but its  
> not guaranteed that it won't change in the future (the construction of it).
> 
> -shay.banon
> 
> On Tue, Nov 16, 2010 at 12:21 AM, Gideon Kaplan [gideonkap...@gmail.com](mailto:gideonkap...@gmail.com)wrote:
> 
> > Hi,  
> > We have groovy code like this  
> > public IndexType getType(Index index, String typeName) {  
> > if (index == null || typeName == null) {  
> > throw new SearchException("Index or type name provided was  
> > null!")  
> > }  
> > IndexType returnType = index.indexTypes.find {  
> > it.name == typeName  
> > }
> 
> > ```
> > return returnType
> > 
> > ```
> > 
> > }
> 
> > But now getting stacktraces like  
> > 2010-11-15 14:12:57,300 [http-8083-1] ERROR  
> > errors.GrailsExceptionResolver - Could not find matching constructor  
> > for: org.elasticsearch.search.SearchException(java.lang.String)  
> > groovy.lang.GroovyRuntimeException: Could not find matching  
> > constructor for:  
> > org.elasticsearch.search.SearchException(java.lang.String)  
> > at  
> > com.ticketfly.search.SearchQueryService.getType(SearchQueryService.groovy:  
> > 283)  
> > at com.ticketfly.search.SearchQueryService$getType.call(Unknown  
> > Source)
> 
> > Looking at the method sigs, its asking for a ShardTarget  
> > How does once quickly create a ShardTarget programmatically (from w/in  
> > the code)
> 
> > package org.elasticsearch.search;
> 
> > public static class SearchException extends  
> > org.elasticsearch.ElasticSearchException {  
> > private final org.elasticsearch.search.SearchShardTarget  
> > shardTarget;
> 
> > public SearchException(org.elasticsearch.search.SearchShardTarget  
> > shardTarget, java.lang.String msg) { /\* compiled code \*/ }
> 
> > public SearchException(org.elasticsearch.search.SearchShardTarget  
> > shardTarget, java.lang.String msg, java.lang.Throwable cause) { /\*  
> > compiled code \*/ }
> 
> > public org.elasticsearch.search.SearchShardTarget shard() { /\*  
> > compiled code \*/ }  
> > }
> 
> > Seems like ShardTarget asks for a few things  
> > public static class SearchShardTarget implements  
> > org.elasticsearch.common.io.stream.Streamable, java.io.Serializable{  
> > private java.lang.String nodeId;  
> > private java.lang.String index;  
> > private int shardId;
> 
> > private SearchShardTarget() { /\* compiled code \*/ }
> 
> > public SearchShardTarget(java.lang.String nodeId, java.lang.String  
> > index, int shardId) { /\* compiled code \*/ }
> 
> > Thanks  
> > G

---

<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:16am UTC](https://discuss.elastic.co/t/searchexception-constructor-changed-in-0-12-1-were-upgrading-from-0-9-0/3575/4 "2017-07-06T04:16:29Z")

</div>

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


