Closed burzum closed 8 years ago
Is there any way to get the underlying Elastica instance/query somehow?
Query::compileQuery() will give you an instance of the query that would be used if the query was executed at that point in time. The Elastica\Query object is only made when a query is executed.
How can I influence / build my own mapping? Looks like MappingSchema is doing it automatically, but how can I override this, for example when I want to use longitude latitude? AFAIR this can be it's own type
Do you mean to define the mapping, or read it? The MappingSchema, just uses elasticsearch's mapping API's to fetch the mappings defined in a type. If you are not pre-defining your mappings outside of this plugin, then I suspect elasticsearch is automatically generating the mapping information.
A few examples for the query builder would be awesome. The best something that reassembles the examples from the elastic documentation.
Any specific examples you'd like to see?
Do you mean to define the mapping, or read it?
Pre-defining. I haven't tested it yet, but in our old app the mapping was done manually. So far it looks like the plugin is doing a good job on auto-detecting the right types. What I did so far is getting an entity from the accounts table and just saved it using the TypeRegistry to an index and type. It converted it OK. I'll have to test it with longitude and latitude, I know that Elastic supports data types for geo-information.
Any specific examples you'd like to see?
For the examples I would like to see something like a full text search across multiple types with the optional part of specifying a few specific fields with AND/OR. But this is not required if I can get the instance of the search query, because this allows me to use the existing code from a legacy app. The only part that might not work then out of the box is pagination?
ElasticSearch always tries to detect the mapping for you. You can override this behaviour for all or specific fields by creating a shell script or something similar. (same goes for deleting, creating, resetting your index)
I'm currently starting to use the elastic ORM in a production e-commerce application with semi-complex aggregation and filtering support and i'm actually having very good results!
/**
* [mapping description]
* @return [type] [description]
*/
public function mapping()
{
$this->out('Sending mapping');
$filterConfig = Configure::read('Product.filters');
$type = $this->_index->getType($this->_indexName);
$mapping = new \Elastica\Type\Mapping();
$mapping->setType($type);
$items = [
'name' => [ 'type' => 'string', 'index' => 'not_analyzed' ]
];
foreach ($filterConfig as $field => $config) {
$items[$field] = [
'type' => 'object',
'properties' => [
'name' => [ 'type' => 'string', 'index' => 'not_analyzed' ],
'id' => [ 'type' => 'string', 'index' => 'not_analyzed' ]
]
];
}
$mapping->setProperties($items);
$mapping->send();
}
@burzum You have to define the mapping yourself ahead of time. We cannot do it as part of the plugin for a few reasons: