i installed the ONGR ElasticSearchBundle in my Symfony Project. To search a Index with Company Names and Descriptions, the index Name is companies. It looks this way:
"mappings": {
"_doc": {
"properties": {
"id": {"type": "long"},
"entityid": {"type": "long"},
"entityname": {"type": "keyword"},
"name": {"type": "text"},
"street": {"type": "text"},
"city": {"type": "text"},
"zip": {"type": "long"},
"ziptext": {"type": "keyword"},
"regionisocode": {"type": "keyword"},
"desc": {"type": "text"},
"branch": {"type": "text"},
"branchid": {"type": "long"},
"foundingyear": {"type": "date"}
}
}
}
Then i used the console tool to create a Document.
/**
* Company
*
* @ES\Document()
*/
class Company
{
/**
* @var string
*
* @ES\Property(type="long", options={"index"="not_analyzed"})
*/
private $id;
/**
* @var string
*
* @ES\Property(type="long", options={"index"="not_analyzed"})
*/
private $entityid;
/**
* @var string
*
* @ES\Property(type="keyword", options={"index"="not_analyzed"})
*/
private $entityname;
...
This seems to work so far. The connection to the ElasicSearch host is working, but i don't get a search result even if i do a MatchAllQuery() i asume that this is an mapping issue? Mayby someone has a hint?
Sincerely
Don't have any experience with the tooling you're using (next to ES), but have you actually indexed/inserted any documents?
If you have ES running locally, try out:
localhost:9200/companies/_searchto verify if there are any documents and whether the index has actually been created.Did you follow these steps? Also here you can find some more information about indexing data.
Happy coding! :D