# Question about :Fs rivers ,synonyms and elasticsearch java api

**URL:** <https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167>\
**Category:** Elasticsearch\
**Created:** [March 15, 2013, 9:02am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167 "2013-03-15T09:02:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 9:02am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/1 "2013-03-15T09:02:27Z")

</div>

I use rivers (fs river and jdbc river) to index documents, I use java api  
for keyword search, I want to use synonyms in my research,

for example when I type the word Application, documents that contain the  
word ios or windows will be in the list of results,

can I load a dictionary at the time of research in which you will find all  
synonyms?

i have the following query :

```
            QueryBuilder query = QueryBuilders.queryString(keyword);

```

SearchResponse searchHits = esClient.prepareSearch()  
.setIndices(INDEX\_NAME\_DOC).setTypes(INDEX\_TYPE\_DOC)  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setFrom(start).setSize(size)  
.setQuery(query).addHighlightedField("name")  
.addHighlightedField("file")  
.execute().actionGet();

how can I modify it to accept synonyms ?

How can i porceed,

Cordially.

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2013, 9:05am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/2 "2013-03-15T09:05:40Z")

</div>

IMHO, to use synonyms you should define it in mapping before indexing.

That way a document containing word will be indexed under microsoft for example.  
When searching, Elasticsearch will apply the same analyzer. If you search for word, your search will be converted to microsoft and you will find your doc.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 15 mars 2013 à 10:02, Ammar Yahia [yahia.ammar.info@gmail.com](mailto:yahia.ammar.info@gmail.com) a écrit :

> I use rivers (fs river and jdbc river) to index documents, I use java api for keyword search, I want to use synonyms in my research,
> 
> for example when I type the word Application, documents that contain the word ios or windows will be in the list of results,
> 
> can I load a dictionary at the time of research in which you will find all synonyms?
> 
> i have the following query :
> 
> ```
> QueryBuilder query = QueryBuilders.queryString(keyword);
> SearchResponse searchHits = esClient.prepareSearch()
> .setIndices(INDEX_NAME_DOC).setTypes(INDEX_TYPE_DOC)
> .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
> .setFrom(start).setSize(size)
> .setQuery(query).addHighlightedField("name")
> .addHighlightedField("file")
> .execute().actionGet();
> 
> ```
> 
> how can I modify it to accept synonyms ?
> 
> How can i porceed,
> 
> Cordially.
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 9:15am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/3 "2013-03-15T09:15:48Z")

</div>

thx for the reply, i use fs river to index document, how can I change the  
mapping when i creat river to accept synonyms ?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2013, 9:36am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/4 "2013-03-15T09:36:55Z")

</div>

You have to create the mapping before creating the river. See: [GitHub - dadoonet/fscrawler: Elasticsearch File System Crawler (FS Crawler)](https://github.com/dadoonet/fsriver#creating-your-own-mapping-analyzers)  
About synonyms, see: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)

Note that the required steps are:  
1/ create index with its analyzer  
2/ create mapping that will use this analyzer  
3/ create the river

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 15 mars 2013 à 10:15, Ammar Yahia [yahia.ammar.info@gmail.com](mailto:yahia.ammar.info@gmail.com) a écrit :

> thx for the reply, i use fs river to index document, how can I change the mapping when i creat river to accept synonyms ?
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 3:11pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/5 "2013-03-15T15:11:57Z")

</div>

_I created an index that contains a simple analyser application =\>  
Applications :_

curl -XPUT '[http://localhost:9200/mydocu/](http://localhost:9200/mydocu/)' -d '{  
"settings" : {"index" : {"analysis" : {"analyzer" : { "synonym" :  
{"tokenizer" : "whitespace","filter" : ["synonym"]} },"filter" : {"synonym"  
: {"type" : "synonym", "ignore\_case" : true, "synonyms" :  
["application =\> applications"]}}}}}}'

_and I used the following mapping :_

curl -XPUT '[http://localhost:9200/mydocu/docu/\_mapping](http://localhost:9200/mydocu/docu/_mapping)' -d '  
{  
"docu" : {  
"properties" : {"file" : {"type" : "attachment","path" :  
"full","fields" : {"file" : {"type" : "string","store" :  
"yes","term\_vector" : "with\_positions\_offsets","index" :  
"analyzed","analyzer" : "french"},"author" : {"type" : "string"},"title" :  
{"type" : "string","store" : "yes"}, "name" : {"type" : "string"},"date" :  
{"type" : "date","format" : "dateOptionalTime"},"keywords" : {"type" :  
"string"},"content\_type" : {"type" : "string" }}}, "name" : {"type" :  
"string","analyzer" : "keyword"},"pathEncoded" : {"type" :  
"string","analyzer" : "keyword"}, "postDate" : {"type" : "date","format" :  
"dateOptionalTime"},"rootpath" : {"type" : "string","analyzer" :  
"keyword"},"virtualpath" : { "type" : "string","analyzer" : "keyword"}}}}'

- and i create the following river:\*

curl -XPUT 'localhost:9200/\_river/riverdocu/\_meta' -d '{  
"type": "fs",  
"fs": {  
"name": "document river",  
"url": "C:\tempDoc",  
"update\_rate": 180000,  
"includes": ["_.doc" , "_.xls", "_.pdf", "_.txt"]  
},  
"index": {  
"index": "mydocu",  
"type": "docu",  
}  
}'

\*but I get this error when the river trying to search for documents :

[2013-03-15 16:01:10,015][DEBUG][action.search.type] [Arcademan] [1]  
Failed to execute fetch phase  
org.elasticsearch.transport.RemoteTransportException:  
[Loa][inet[/172.16.10.61:9301]][search/phase/fetch/id]  
Caused by: org.elasticsearch.indices.TypeMissingException: [\_river]  
type[riverdocu] missing: failed to find type loaded for doc [\_meta]  
at  
org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:165)  
at  
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:438)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:634)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:623)  
at  
org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:268)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
\*

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2013, 3:20pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/6 "2013-03-15T15:20:14Z")

</div>

Did you clean the \_river before redoing all your test?  
Sounds like a \_river doc is remaining somewhere in your cluster.

Are you running a multimode cluster or are you in standalone?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 15 mars 2013 à 16:11, Ammar Yahia [yahia.ammar.info@gmail.com](mailto:yahia.ammar.info@gmail.com) a écrit :

> I created an index that contains a simple analyser application =\> Applications :
> 
> curl -XPUT '[http://localhost:9200/mydocu/](http://localhost:9200/mydocu/)' -d '{  
> "settings" : {"index" : {"analysis" : {"analyzer" : { "synonym" : {"tokenizer" : "whitespace","filter" : ["synonym"]} },"filter" : {"synonym" : {"type" : "synonym", "ignore\_case" : true, "synonyms" : ["application =\> applications"]}}}}}}'
> 
> and I used the following mapping :
> 
> curl -XPUT '[http://localhost:9200/mydocu/docu/\_mapping](http://localhost:9200/mydocu/docu/_mapping)' -d '  
> {  
> "docu" : {  
> "properties" : {"file" : {"type" : "attachment","path" : "full","fields" : {"file" : {"type" : "string","store" : "yes","term\_vector" : "with\_positions\_offsets","index" : "analyzed","analyzer" : "french"},"author" : {"type" : "string"},"title" : {"type" : "string","store" : "yes"}, "name" : {"type" : "string"},"date" : {"type" : "date","format" : "dateOptionalTime"},"keywords" : {"type" : "string"},"content\_type" : {"type" : "string" }}}, "name" : {"type" : "string","analyzer" : "keyword"},"pathEncoded" : {"type" : "string","analyzer" : "keyword"}, "postDate" : {"type" : "date","format" : "dateOptionalTime"},"rootpath" : {"type" : "string","analyzer" : "keyword"},"virtualpath" : { "type" : "string","analyzer" : "keyword"}}}}'
> 
> and i create the following river:
> 
> curl -XPUT 'localhost:9200/\_river/riverdocu/\_meta' -d '{  
> "type": "fs",  
> "fs": {  
> "name": "document river",  
> "url": "C:\tempDoc",  
> "update\_rate": 180000,  
> "includes": ["_.doc" , "_.xls", "_.pdf", "_.txt"]  
> },  
> "index": {  
> "index": "mydocu",  
> "type": "docu",  
> }  
> }'
> 
> but I get this error when the river trying to search for documents :
> 
> [2013-03-15 16:01:10,015][DEBUG][action.search.type] [Arcademan] [1] Failed to execute fetch phase  
> org.elasticsearch.transport.RemoteTransportException: [Loa][inet[/172.16.10.61:9301]][search/phase/fetch/id]  
> Caused by: org.elasticsearch.indices.TypeMissingException: [\_river] type[riverdocu] missing: failed to find type loaded for doc [\_meta]  
> at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:165)  
> at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:438)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:634)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:623)  
> at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:268)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:662)
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 3:28pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/7 "2013-03-15T15:28:29Z")

</div>

i'm in standalone, and i use two fs river with name : newriver1 and mydocs  
, should i delete those rivers before creating my new river riverdocu ?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2013, 3:54pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/8 "2013-03-15T15:54:03Z")

</div>

Hmmmm. No. I don't think you have to.  
That said if you are running tests, I suggest that you clean every time your environment before running new tests.

I can't say here what this happens.

Are you sending curl commands or doing this from Java?  
Are you waiting a little (wait for cluster yellow status for example) after the index creation?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 15 mars 2013 à 16:28, Ammar Yahia [yahia.ammar.info@gmail.com](mailto:yahia.ammar.info@gmail.com) a écrit :

> i'm in standalone, and i use two fs river with name : newriver1 and mydocs , should i delete those rivers before creating my new river riverdocu ?
> 
> --  
> 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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 4:52pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/9 "2013-03-15T16:52:54Z")

</div>

it works, i clean the environment, and now it works, and now i have another  
problem :-p

I want when I type the word application, the documents that contain the  
word applications will also be returned,

but I have only documents that contain the word application in the result  
list,

_i have the folowing index with its analyser:_

curl -XPUT '[http://localhost:9200/docum/](http://localhost:9200/docum/)' -d '{  
"settings" : {"index" : {"analysis" : {"analyzer" : { "synonym" :  
{"tokenizer" : "whitespace","filter" : ["synonym"]} },"filter" : {"synonym"  
: {"type" : "synonym", "ignore\_case" : true, "synonyms" : ["application =\>  
applications"]}}}}}}'

_and the following mapping:_

curl -XPUT '[http://localhost:9200/docum/mydocu/\_mapping](http://localhost:9200/docum/mydocu/_mapping)' -d '  
{  
"mydocu" : {  
"properties" : {  
"file" : { "type" : "attachment","path" : "full",  
"fields" : {"file" : {"type" : "string","store" :  
"yes","term\_vector" : "with\_positions\_offsets","index" : "analyzed"},  
"author" : {"type" : "string"},  
"title" : {"type" : "string","store" : "yes"},  
"name" : {"type" : "string"},  
"date" : {"type" : "date","format" : "dateOptionalTime"},  
"keywords" : {"type" : "string"},  
"content\_type" : {"type" : "string" }}},  
"name" : {"type" : "string","analyzer" : "keyword"},  
"pathEncoded" : {"type" : "string","analyzer" : "keyword"},  
"postDate" : {"type" : "date","format" : "dateOptionalTime"},  
"rootpath" : {"type" : "string","analyzer" : "keyword"},  
"virtualpath" : { "type" : "string","analyzer" : "keyword"}}}}'

_is that I made a mistake in the declaration required of the index or  
mapping ?_

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yahia](https://avatars.discourse-cdn.com/v4/letter/y/d9b06d/32.png) [@yahia](https://discuss.elastic.co/u/yahia)\
**Post date:** [March 15, 2013, 4:56pm UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/10 "2013-03-15T16:56:13Z")

</div>

_I also use this code to search :_

QueryBuilder query = QueryBuilders.queryString(keyword);  
SearchResponse searchHits = esClient.prepareSearch()  
.setIndices(INDEX\_NAME).setTypes(INDEX\_TYPE\_DOC)  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setFrom(start).setSize(size)  
.setQuery(query)  
.addHighlightedField("name")  
.addHighlightedField("file")  
.setHighlighterPreTags("")  
.setHighlighterPostTags("").execute().actionGet();

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:46am UTC](https://discuss.elastic.co/t/question-about-fs-rivers-synonyms-and-elasticsearch-java-api/11167/11 "2017-07-06T02:46:16Z")

</div>


