Have a look also here :
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticse
arch/river/rss/AbstractRssRiverTest.java
Here is a line to create an index named "rss"
node.client().admin().indices().create(new
CreateIndexRequest("rss")).actionGet();
Here is the mapping for the page type
It contains 5 properties :
source (type string)
title (type string, french analyzer)
description (type string, french analyzer)
author (type string)
link (type string)
XContentBuilder xbMapping =
jsonBuilder()
.startObject()
.startObject("page")
.startObject("properties")
.startObject("source")
.field("type", "string")
.endObject()
.startObject("title")
.field("type", "string")
.field("analyzer", "french")
.endObject()
.startObject("description")
.field("type", "string")
.field("analyzer", "french")
.endObject()
.startObject("author")
.field("type", "string")
.endObject()
.startObject("link")
.field("type", "string")
.endObject()
.endObject()
.endObject()
.endObject();
You put the mapping in the rss index for the page type
node.client().admin().indices()
.preparePutMapping("rss")
.setType("page")
.setSource(xbMapping)
.execute().actionGet();
You can find docs : Elasticsearch Platform — Find real-time answers at scale | Elastic
and core types
(Elasticsearch Platform — Find real-time answers at scale | Elastic )
Elasticsearch Platform — Find real-time answers at scale | Elastic
tml
There is a nice search engine on top of Elasticsearch site which is very
useful to find your way in the documentation
Not sure of what you are looking after...
HTH,
David.
-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de Frank LaRosa
Envoyé : vendredi 6 janvier 2012 22:07
À : elasticsearch
Objet : Re: Creating mappings via the Java API
Where do I find a list of all the possible properties and their
values? I don't see this in the documentation.
On Jan 6, 1:04 pm, David Pilato da...@pilato.fr wrote:
You can have a look here
:https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/el.
..
David
@dadoonet
Le 6 janv. 2012 à 19:54, Frank LaRosa fr...@studyblue.com a écrit :
Hi,
I'm just getting started with Elasticsearch. My first goal is to
create a particular index. I'm an experienced Solr/Lucene user, so
I've already designed what I want in terms of field names, types,
analyizers, etc.
I'm a little confused by the Java API, which seems to be sparsely
documented with few examples. In particular, the API for adding a
mapping during index creation is (I think) the mapping() function
in
CreateIndexRequest. There are three variants of this method, one
that
takes a java.util.Map, one that takes a String, and one that takes
an
object called XContentBuilder with which I am not familiar.
I have no idea what to do here. The documentation doesn't tell me
what
the API is looking for in the map or the string.
I found some documentation showing what the mapping looks like in
the
JSON API, but I can't find any objects in the Java API that seem to
have the field names or structure shown in the JSON.
Can anyone point me in the right direction or show me an example?
Thanks.
Frank