API for create type

Hi,
maybe there is another way around this but my problem started with a
search query that had an index and type already created.The query always
returned a SearchResult. So I built my logic around that, i.e using the
SearchResult object in my JSP page.

But when I restarted fresh I had no index and type created (only a
mapping file) and as such I got some IndexMissing excpetions instead. I
then created the index. But I still got exception due to the type that
was missing.

There seems not to be a way to create a type. The only way to have the
type created is to insert a dummy document and remove it. That way I
finally got the SerachResult with 0 hits wich I expected in the first run...

Of course I could create some logic in the JSP page to handle null
values for the SearchResult, but that would be much messier. I even
tried to create an empty SearchResult, but there was no public
constructor...

So, I would love if there was a way to create the type (which would put
the index in a a state equal to that when the type exists, but has 0
documents).

/Kristian

Hi Kristian

So, I would love if there was a way to create the type (which would put
the index in a a state equal to that when the type exists, but has 0
documents).

or when you create the index:

clint

Yes, I am aware of the put-mapping API, but I do not put mappings
explicitly from code. I have a mappings file that set things up. I could
not find a way to put a mapping with reference to that file. If that
exists all is well.

/Kristian

Clinton Gormley skrev 2011-04-22 17:50:

Hi Kristian

So, I would love if there was a way to create the type (which would put
the index in a a state equal to that when the type exists, but has 0
documents).
Elasticsearch Platform — Find real-time answers at scale | Elastic

or when you create the index:

Elasticsearch Platform — Find real-time answers at scale | Elastic

clint