Constructing mappings (apologies for repost)

Hi, my apologies for the repost - the last one was posted only half
written and I cannot work out how to delete it

In my elasticsearch.yml file am trying to implement some mapping where one
field belonging to one type is indexed using a different analyzer to the
rest.

At present I have the following structure in my elasticsearch.yml file:

Index Settings

index:
bookshelf:
types:
book:
mappings:
title: {analyzer: customAnalyzer}
analysis:
analyzer:
# set standard analyzer with no stop words as the default for both
indexing and searching
default:
type: standard
stopwords: none
# set custom analyser to provide a more detailed search result
customAnalyzer:
type: custom
tokenizer: nGramTokenizer
filter: [lowercase,stopWordsFilter,asciifolding]
tokenizer:
nGramTokenizer:
type: nGram
min_gram: 1
max_gram: 2
filter:
nGramFilter:
type: nGram
min_gram: 1
max_gram: 2
stopWordsFilter:
type: stop
stopwords: none

This does not apply the custom analyzer to the title field, so I was hoping
someone may be able to point me in the right direction for applying custom
analyzers to individual fields?

--

If you are using Java you don't have to use an yml file. You can, but you don't
have to.

If you are using Spring, you can have a look at the ES spring factory project:
GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch
https://github.com/dadoonet/spring-elasticsearch
If not, there is different ways of creating index and mappings in Java.

You can have a look here to see how I'm doing this by reading a json mapping
file:
https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616
https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616

You can also use XContent objects provided by ES to build your mappings in Java:
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/RssRiverTest.java#L14
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/RssRiverTest.java#L14

Using this object is described here:
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/AbstractRssRiverTest.java#L98
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/AbstractRssRiverTest.java#L98

node . client (). admin (). indices ()
. preparePutMapping ("yourindex" )
. setType ( "yourtype" )
. setSource ( mapping ())
. execute (). actionGet ();

I hope this could help you

David.

Le 4 octobre 2012 à 14:16, My Head Hurts mathieson10@gmail.com a écrit :

Hi, my apologies for the repost - the last one was posted only half written
and I cannot work out how to delete it

In my elasticsearch.yml file am trying to implement some mapping where one
field belonging to one type is indexed using a different analyzer to the rest.

At present I have the following structure in my elasticsearch.yml file:

Index Settings

index :
bookshelf :
types :
book :
mappings :
title : { analyzer : customAnalyzer }
analysis :
analyzer :
# set standard analyzer with no stop words as the default for both
indexing and searching
default :
type : standard
stopwords : none
# set custom analyser to provide a more detailed search result
customAnalyzer :
type : custom
tokenizer : nGramTokenizer
filter : [ lowercase , stopWordsFilter , asciifolding ]
tokenizer :
nGramTokenizer :
type : nGram
min_gram : 1
max_gram : 2
filter :
nGramFilter :
type : nGram
min_gram : 1
max_gram : 2
stopWordsFilter :
type : stop
stopwords : none

This does not apply the custom analyzer to the title field, so I was hoping
someone may be able to point me in the right direction for applying custom
analyzers to individual fields?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Thanks David, I am not using spring so I shall look into your code a little
more if you do not mind.

I am sure I will find the information very helpful, so thank you.

On Thursday, 4 October 2012 15:01:55 UTC+2, David Pilato wrote:

If you are using Java you don't have to use an yml file. You can, but
you don't have to.

If you are using Spring, you can have a look at the ES spring factory
project: GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch
If not, there is different ways of creating index and mappings in Java.

You can have a look here to see how I'm doing this by reading a json
mapping file:
https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616

You can also use XContent objects provided by ES to build your mappings
in Java:
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/RssRiverTest.java#L14

Using this object is described here:
https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/AbstractRssRiverTest.java#L98

node . client (). admin (). indices ()
. preparePutMapping ("yourindex" )
. setType ( "yourtype" )
. setSource ( mapping ())
. execute (). actionGet ();

I hope this could help you

David.

Le 4 octobre 2012 à 14:16, My Head Hurts <mathi...@gmail.com <javascript:>>
a écrit :

Hi, my apologies for the repost - the last one was posted only half
written and I cannot work out how to delete it

In my elasticsearch.yml file am trying to implement some mapping where one
field belonging to one type is indexed using a different analyzer to the
rest.

At present I have the following structure in my elasticsearch.yml file:

Index Settings

index :
bookshelf :
types :
book :
mappings :
title : { analyzer : customAnalyzer }
analysis :
analyzer :
# set standard analyzer with no stop words as the default for both
indexing and searching
default :
type : standard
stopwords : none
# set custom analyser to provide a more detailed search result
customAnalyzer :
type : custom
tokenizer : nGramTokenizer
filter : [ lowercase , stopWordsFilter , asciifolding ]
tokenizer :
nGramTokenizer :
type : nGram
min_gram : 1
max_gram : 2
filter :
nGramFilter :
type : nGram
min_gram : 1
max_gram : 2
stopWordsFilter :
type : stop
stopwords : none

This does not apply the custom analyzer to the title field, so I was
hoping someone may be able to point me in the right direction for applying
custom analyzers to individual fields?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Yes go ahead. That's why i gave you some pointers. Feel free to ask.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 oct. 2012 à 15:57, My Head Hurts mathieson10@gmail.com a écrit :

Thanks David, I am not using spring so I shall look into your code a little more if you do not mind.

I am sure I will find the information very helpful, so thank you.

On Thursday, 4 October 2012 15:01:55 UTC+2, David Pilato wrote:
If you are using Java you don't have to use an yml file. You can, but you don't have to.

If you are using Spring, you can have a look at the ES spring factory project: GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch
If not, there is different ways of creating index and mappings in Java.

You can have a look here to see how I'm doing this by reading a json mapping file: https://github.com/dadoonet/spring-elasticsearch/blob/master/src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchAbstractClientFactoryBean.java#L616

You can also use XContent objects provided by ES to build your mappings in Java: https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/RssRiverTest.java#L14

Using this object is described here: https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/elasticsearch/river/rss/AbstractRssRiverTest.java#L98

node . client (). admin (). indices ()
. preparePutMapping ("yourindex" )
. setType ( "yourtype" )
. setSource ( mapping ())
. execute (). actionGet ();

I hope this could help you

David.

Le 4 octobre 2012 à 14:16, My Head Hurts mathi...@gmail.com a écrit :

Hi, my apologies for the repost - the last one was posted only half written and I cannot work out how to delete it

In my elasticsearch.yml file am trying to implement some mapping where one field belonging to one type is indexed using a different analyzer to the rest.

At present I have the following structure in my elasticsearch.yml file:

Index Settings

index :
bookshelf :
types :
book :
mappings :
title : { analyzer : customAnalyzer }
analysis :
analyzer :
# set standard analyzer with no stop words as the default for both indexing and searching
default :
type : standard
stopwords : none
# set custom analyser to provide a more detailed search result
customAnalyzer :
type : custom
tokenizer : nGramTokenizer
filter : [ lowercase , stopWordsFilter , asciifolding ]
tokenizer :
nGramTokenizer :
type : nGram
min_gram : 1
max_gram : 2
filter :
nGramFilter :
type : nGram
min_gram : 1
max_gram : 2
stopWordsFilter :
type : stop
stopwords : none

This does not apply the custom analyzer to the title field, so I was hoping someone may be able to point me in the right direction for applying custom analyzers to individual fields?

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--