-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify a DSL for metadata searches #268
Conversation
One idea is to take a small subset of MongoDB query operators, and simply send the query as JSON in a query parameter. The following comparison operators should be supported (taken from http://docs.mongodb.org/manual/reference/operator/query-comparison/):
The following logical operators should be supported (taken from http://docs.mongodb.org/manual/reference/operator/query-logical/):
To do wildcard searches I propose the following operator:
|
Today the Doctrine adapter disallows
|
For case insensitive searches to work in both the Doctrine and MongoDB adapters the data stored in MongoDB will be duplicated, and searches will go against the normalized (lowercased) data. Searches will also be lowercased (for now). |
Before merging this PR the following tasks must be completed:
|
Two issues I've found:
|
An $exists operator would also be nice - useful when you want to return any image that has a metadata key but don't care about the value. |
I discovered a whole bunch of issues in the Doctrine version of the metadata query. Once fixed this PR is getting close to finished. |
…it's sent to the adapters
…rine adapter for now
…for wildcard searches
…schema of the metadata table. I must have been on pretty far out when writing the initial implementation...
…d the method that adds images to also add metadata is specified. Also added a feature file for the metadata query.
…ound a lot of issues in the metadata queries in Doctrine that have not yet been fixed
Given the recent discussion on this, and the conclusion that the functionality should be provided by a plugin and not be part of the core, this looks a bit different. I'll use elasticsearch for metadata search and I suggest using the elasticsearch query DSL as well. It is well thought out, and proven. Thoughts? |
Slightly torn on this. It would certainly make it easier to implement. I'd say if we rename the plugin to have |
In my mind, the point of using a DSL for searching is that is should be possible to easily translate it into whatever query-language the search-provider (Mongo, Elasticsearch, etc) is using. So two things needs to be considered
The reason for this is of course to avoid lock-in and enable many different search-providers. But also to avoid having a leaky abstraction. Should it be Imbo that does the searches, or should Imbo just act as a "proxy" for one specific search-provider (Elasticsearch)? To avoid the latter, it's important to not rely on being able to take a unknown text-blob search-query and just forward it to Elasticsearch. Instead, Imbo must be able to parse the query-DSL and the compile it into a (possible identical) Elasticsearch query. At least that's my to cents. |
Lots of good points here. First; by moving the search feature out of the Imbo core and instead providing it as an addon to Imbo, the requirement of supporting Doctrine and Mongo as search backends is in my opinion not sound. On the point of the DSL you're making a good point of bring able to translate the query into something that is consumeable for different search backends. After some thinking I'm leaning towards making the search plugin easily pluggable and with interfaces that makes integrating other search backends (Solr and Lucene are obvious candidates) fairly easy.. And I'll stick to the DSL proposed by @christeredvartsen in this issue. I'll implement the ES backend only now due to deadlines, but adding other backends sholdn't be a big job. |
@kbrabrand, We, here at TV 2 Danmark, will likely also want to use ES as our metadata search-backend, so let me know if there is anything we can help with, then we can allocate resources for it too. I can try and write a first draft of a Mongo/Imbo search-DSL -> ElasticSearch query transformation, if that has any interest... |
That sounds great @fangel. I think the transformation should be done from the DSL and to something that can be used for querying with the elasticsearch-php client, which is basically just an array with properties. We are running against the clock here in Oslo, so in order to plan the next weeks; do you know what your time frame for this looks like? |
Yes, transforming into elastisearch-php query-parameters sounds like a good approach. It should be easy to write some unit-tests for the test-cases we care about and write a transformation that fits these... And we're have scheduling our implementation beginning this week, so we can help from today if necessary. |
That sounds awesome, @fangel! |
@fangel: @christeredvartsen implemented the transformations for mongo for this issue, so you might want to take a look at the implementation and tests. It was done a while ago, so I applied the commits to a recent version of develop when I picked up this task last week; https://github.com/kbrabrand/imbo/tree/issue-268 |
Metadata search is implemented as a separate project/plugin, see https://github.com/imbo/imbo-metadata-search. Closing this. |
Imbo needs to be able to perform metadata searches against the images resource, and for this we need to specify a DSL.
Metadata is usually
key => value
pairs, the can also have nestedkey => value
pairs. The search needs to support this along with other basic operations.