ONGR ElasticSearchBundle Mapping in Document Class

245 Views Asked by At

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

1

There are 1 best solutions below

1
Byron Voorbach On

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/_search to 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