Hi guys today I have faced problem with couchdb and elastic search.
I read all manuals about elastic search and couchdb, maybe I do not understand something.
I will describe what I am doing below:
I have created elastcsearch.yml
cluster:
name: alejandros_cluster
# Gateway Settings
#gateway:
# recover_after_nodes: 1
# recover_after_time: 5m
# expected_nodes: 2
# ascii folding http://elasticsearch-users.115913.n3.nabble.com/Question-about-asciifolding-filter-td1525600.html
index:
analysis:
analyzer:
asciisafe:
type: custom
tokenizer: standard
filter: [standard, lowercase, asciifolding, stop]
I have created new index.json
"index" : {
"analysis" : {
"analyzer" : {
"default" : {
"tokenizer" : "standard",
"filter" : ["standard", "asciifolding"]
}
}
}
}
The I have created mapping file mapping_competitions.json
{
"competitions" :
{
"type":"object"
, "dynamic": false
, "properties" :
{
"competition_id":
{
"type" : "string"
}
, "name":
{
"type" : "string"
, "analyzer":"asciisafe"
}
, "area_name":
{
"type" : "string"
, "analyzer":"asciisafe"
}
}
}
}
Then I have created river_competitions.json file
{
"type":"couchdb",
"couchdb":{
"host":"localhost",
"port":5984,
"db":"fbm_stats",
"filter":"api/competitions",
"user":"fbmimport",
"password":"fbmimport"
},
"index": {
"index" : "fbm_competitions_index",
"type" : "competitions",
"bulk_size" : "110",
"bulk_timeout" : "11ms"
}
}
api/competitions - is the view which is in emits such result :
{competition_id: "1", name: "Eredivisie", type: "club", area_id: "138", area_name: "Netherlands", format: "Domestic league", display_order: "10", last_season: "9823"}
Add here is my sh file
#!/bin/bash
#
# Deleting
#
#delete river
curl -vXDELETE http://localhost:9200/_river/river_fbm_competitions_index
echo '\nRIVER WAS DELETED'
#delete mapping
curl -vXDELETE http://localhost:9200/fbm_competitions_index/competitions
echo '\nMAPPING WAS DELETED'
#delete index
curl -vXDELETE http://localhost:9200/fbm_competitions_index
echo '\nINDEX WAS DELETED'
#
# Creation
#
#create index
curl -vXPUT http://localhost:9200/fbm_competitions_index -d @index.json
echo '\nINDEX WAS created'
#create mapping
curl -vXPUT 'http://localhost:9200/fbm_competitions_index/competitions/_mapping' -d @mapping_competitions.json
echo '\nMAPPING WAS CREATED'
# import couch data
curl -vXPUT 'http://localhost:9200/_river/river_fbm_competitions_index/_meta' -d @river_competitions.json
echo '\nIMPORTING COUCH DATA'
After running this code I get such log
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> DELETE /_river/river_fbm_competitions_index HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Content-Length: 11
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"ok":true}
RIVER WAS DELETED
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> DELETE /fbm_competitions_index/competitions HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: application/json; charset=UTF-8
< Content-Length: 98
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"error":"TypeMissingException[[fbm_competitions_index] type[competitions] missing]","status":404}
MAPPING WAS DELETED
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> DELETE /fbm_competitions_index HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Content-Length: 31
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"ok":true,"acknowledged":true}
INDEX WAS DELETED
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> PUT /fbm_competitions_index HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
> Content-Length: 200
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 200out of 200 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Content-Length: 31
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"ok":true,"acknowledged":true}
INDEX WAS created
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> PUT /fbm_competitions_index/competitions/_mapping HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
> Content-Length: 447
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 447out of 447 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=UTF-8
< Content-Length: 96
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"error":"MapperParsingException[Analyzer [asciisafe] not found for field [name]]","status":400}
MAPPING WAS CREATED
* About to connect() to localhost port 9200 (#0)
* Trying 127.0.0.1... connected
> PUT /_river/river_fbm_competitions_index/_meta HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:9200
> Accept: */*
> Content-Length: 362
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 362out of 362 bytes
< HTTP/1.1 201 Created
< Content-Type: application/json; charset=UTF-8
< Content-Length: 95
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"ok":true,"_index":"_river","_type":"river_fbm_competitions_index","_id":"_meta","_version":1}
IMPORTING COUCH DATA
here is a result from this river index
{
took: 1,
timed_out: false,
_shards: {
total: 5,
successful: 5,
failed: 0
},
hits: {
total: 0,
max_score: null,
hits: [ ]
}
}
Can somebody give me a hand?