# Configuration for synonym

**URL:** <https://discuss.elastic.co/t/configuration-for-synonym/7705>\
**Category:** Elasticsearch\
**Created:** [May 15, 2012, 3:59pm UTC](https://discuss.elastic.co/t/configuration-for-synonym/7705 "2012-05-15T15:59:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vgross](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@vgross](https://discuss.elastic.co/u/vgross)\
**Post date:** [May 15, 2012, 3:59pm UTC](https://discuss.elastic.co/t/configuration-for-synonym/7705/1 "2012-05-15T15:59:58Z")

</div>

I ! I try to use Elastic Search for my Website and i have a configuration problem !

First i edit the file '/usr/local/elasticsearch/config/elasticsearch.yml' with :

cluster.name: mycluster

Then I edit '/etc/elasticsearch/elasticsearch.yml' with :

cluster:  
name: mycluster

index:  
analysis:  
analyzer:  
syns:  
tokenizer : standard  
filter : syn\_filter

```
    filter:
        syn_filter:
            type: synonym
            synonyms_path: /etc/elasticsearch/synonym.txt

```

finally i edit my synonym file '/etc/elasticsearch/synonym.txt' with :

cool =\> sympa

In my script 'index.php' , i use [https://github.com/nervetattoo/elasticsearch](https://github.com/nervetattoo/elasticsearch), first i execute :

require\_once "ElasticSearchClient.php";

$transport = new ElasticSearchTransportHTTP("localhost", 9200);  
$search = new ElasticSearchClient($transport, "myindex", "mytype");  
var\_dump($search-\>index(array('title' =\> 'My cool document')));  
var\_dump($search-\>index(array('title' =\> 'My second cool document')));

and the result is :

array(5) {  
["ok"]=\>  
bool(true)  
["\_index"]=\>  
string(7) "myindex"  
["\_type"]=\>  
string(6) "mytype"  
["\_id"]=\>  
string(22) "olRN5Z2WQo61b74MKnp2DQ"  
["\_version"]=\>  
int(1)  
}  
array(5) {  
["ok"]=\>  
bool(true)  
["\_index"]=\>  
string(7) "myindex"  
["\_type"]=\>  
string(6) "mytype"  
["\_id"]=\>  
string(22) "Ly-Q-mISSm2Jt4HnEcaqww"  
["\_version"]=\>  
int(1)  
}

But here, it's ok, my 2 documents are now in my index "myindex"  
Then i execute my script like this :

require\_once "ElasticSearchClient.php";

$transport = new ElasticSearchTransportHTTP("localhost", 9200);  
$search = new ElasticSearchClient($transport, "myindex", "mytype");

var\_dump($search-\>search('title:cool'));  
var\_dump($search-\>search('title:sympa'));

and the result is :  
array(5) {  
["took"]=\>  
int(2)  
["timed\_out"]=\>  
bool(false)  
["\_shards"]=\>  
array(3) {  
["total"]=\>  
int(5)  
["successful"]=\>  
int(5)  
["failed"]=\>  
int(0)  
}  
["hits"]=\>  
array(3) {  
["total"]=\>  
int(2)  
["max\_score"]=\>  
float(0.2972674)  
["hits"]=\>  
array(2) {  
[0]=\>  
array(5) {  
["\_index"]=\>  
string(7) "myindex"  
["\_type"]=\>  
string(6) "mytype"  
["\_id"]=\>  
string(22) "9nPVEj6DT-65KfKuJvJ9QQ"  
["\_score"]=\>  
float(0.2972674)  
["\_source"]=\>  
array(1) {  
["title"]=\>  
string(16) "My cool document"  
}  
}  
[1]=\>  
array(5) {  
["\_index"]=\>  
string(7) "myindex"  
["\_type"]=\>  
string(6) "mytype"  
["\_id"]=\>  
string(22) "f67TBpqMQimBiBkD5FZv\_g"  
["\_score"]=\>  
float(0.2972674)  
["\_source"]=\>  
array(1) {  
["title"]=\>  
string(23) "My second cool document"  
}  
}  
}  
}  
["time"]=\>  
float(0.0040738582611084)  
}  
array(5) {  
["took"]=\>  
int(1)  
["timed\_out"]=\>  
bool(false)  
["\_shards"]=\>  
array(3) {  
["total"]=\>  
int(5)  
["successful"]=\>  
int(5)  
["failed"]=\>  
int(0)  
}  
["hits"]=\>  
array(3) {  
["total"]=\>  
int(0)  
["max\_score"]=\>  
NULL  
["hits"]=\>  
array(0) {  
}  
}  
["time"]=\>  
float(0.0020260810852051)  
}

I don't understand why my second request don't find my cool document ? I think i make a mistake but after 1 day of search, i don't find it ! Please help me !

PS: when i try URL : [http://192.168.1.35:9200/\_analyze?pretty=1&text=cool&analyzer=syns](http://192.168.1.35:9200/_analyze?pretty=1&text=cool&analyzer=syns) the result is :

{  
"error" : "ElasticSearchIllegalArgumentException[failed to find analyzer [syns]]",  
"status" : 400  
}

Thanx

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:28am UTC](https://discuss.elastic.co/t/configuration-for-synonym/7705/2 "2017-07-06T03:28:48Z")

</div>


