Hi Dom
First, make sure you're using the new Search::Elasticsearch client
https://metacpan.org/pod/Search::Elasticsearch - we've just renamed it to
avoid namespace clashes with older clients.
Then: to configure the mapping yourself, you need to do it before you index
any data (using the bulk method or any other indexing method).
The full Elasticsearch REST API is supported by the Perl client, eg:
1) at index creation time:
$es->indices->create(
index => 'myindex',
body => {
mappings=> {
mytype => {...mapping definition...}
}
}
);
See
https://metacpan.org/pod/Search::Elasticsearch::Client::Direct::Indices#create
2) Update mapping API (note, you can't change existing mappings, just add
new fields/types):
$es->indices->put_mapping(
index => 'myindex',
type => 'mytype',
body => { ... mapping definition ... }
)
See
https://metacpan.org/pod/Search::Elasticsearch::Client::Direct::Indices#put_mapping
clint
On 10 March 2014 15:35, Dominic Nicholas <[email protected]>wrote:
> Hi,
>
> I'm using the Elasticsearch Perl module and need guidance on setting up
> mappings.
> I'm using the bulk() method to index data. Here is an example of the
> structure of the data :
>
> $response = $e->bulk(
> "index" : "idx-2014.03.10",
> "type" : "my_type",
> "body" : [
> {
> "index" : {
> "_index" : "idx-2014.03.10",
> "_id" : "4410",
> "_type" : "my_type"
> }
> },
> {
> "something" : "interesting",
> "somethingelse" : "also interesting"
> },
> {
> "index" : {
> "_index" : "idx-2014.03.10",
> "_id" : "4411",
> "_type" : "my_type"
> }
> },
> {
> "something" : "very interesting",
> "somethingelse" : "not interesting"
> }
> ]
> );
>
> How do I set up mappings on various fields in the above example for
> 'something' and 'somethingelse' fields ?
> Also, how do I turn off the analyzer for an index (index: not_analyzed)
> too ?
>
> I know there are several ways of setting up mappings such as :
>
> - when creating an index
> - by using the dedicated update mapping api
> - using index templates
>
> Ideally I'd like to use the dedicated update mapping api but am unclear
> how to use that through the Perl library interface (eg use
> transport->perform_request()
> ?).
>
> Thanks for any guidance and help.
>
> Dom
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/f310961e-c389-49ea-82c9-c47d71d32209%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/f310961e-c389-49ea-82c9-c47d71d32209%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQhLPNsGhugoaYqWisBuKRp73oD%2BHcRDi2GE85iH8MrpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.