PHPackages                             imbo/imbo-metadata-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. imbo/imbo-metadata-search

AbandonedArchivedLibrary[Search &amp; Filtering](/categories/search)

imbo/imbo-metadata-search
=========================

Metadata search plugin for Imbo

2.1.0(10y ago)38604[2 issues](https://github.com/imbo/imbo-metadata-search/issues)MITPHPPHP &gt;=5.5.0

Since Mar 12Pushed 8y ago5 watchersCompare

[ Source](https://github.com/imbo/imbo-metadata-search)[ Packagist](https://packagist.org/packages/imbo/imbo-metadata-search)[ RSS](/packages/imbo-imbo-metadata-search/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (10)Used By (0)

[![Current build Status](https://camo.githubusercontent.com/3b44022cb98b38256e641c81a264fbee2a88da69b9c401c3202b604e9959304a/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f696d626f2f696d626f2d6d657461646174612d7365617263682e706e67)](http://travis-ci.org/imbo/imbo-metadata-search)

Metadata search plugin for Imbo
===============================

[](#metadata-search-plugin-for-imbo)

The metadata search event listener hooks onto metadata updates for your images and keeps the search backend of your choice up to date, and allows you to find images by querying its metadata.

Installation
------------

[](#installation)

### Setting up the dependencies

[](#setting-up-the-dependencies)

If you've installed Imbo through composer, getting the metadata search up and running is really simple. Simply add `imbo/imbo-metadata-search` as a dependency.

In addition to the metadata search plugin you'll need a search backend client. Right now the plugin ships with support for elasticsearch only, so you'll want to add `elasticsearch/elasticsearch` as well in order to be able to use it as search backend.

```
{
    "require": {
        "imbo/imbo-metadata-search": "dev-master",
        "elasticsearch/elasticsearch": "~2.1"
    }
}
```

The elasticsearch plugin requires that your elasticsearch server is at least version 2.0.

### Metadata search setup

[](#metadata-search-setup)

In order for the metadata search plugin to be registered and actually do something usedful for your Imbo installation you need to add a config file which declares the routes, resource and event listeners.

After installing with composer you will find a basic config file for the metadata search in `vendor/imbo/imbo-metadata-search/config.dist.php`. If you want to make changes to the file you should copy it to your config folder.

Indexing
--------

[](#indexing)

Updates in the search backend is triggered whenever one of the following events are fired; `image.delete`, `images.post`, `image.post`, `metadata.post`, `metadata.put`, `metadata.delete`.

The `image.delete` event triggers a delete in the indexed object in the search backend, and the other ones trigger an update of the full object. When indexing, data in addition to metadata is provided to the search backend for indexin in order to sorting and such.

The data provided to the backend are;

DataDescription`user`The user "owning" the image`size`Byte size of image`extension`File extension`mime`Mime type of file`metadata`Image metadata`added`Timestamp representation of when the image was added`updated`Timestamp representation of when the image was last updated`width`Width of image in pixels`height`Height of image in pixelsQuerying
--------

[](#querying)

Querying is done by issuing an HTTP SEARCH request to `/users//images` if you want to search in the images of a single user, or `/images` if you want to search across multiple users. Supported query parameters are:

ParamDescription`page`The page number. Defaults to 1.`limit`Number of images per page. Defaults to 20.`metadata`Whether or not to include metadata in the output. Defaults to 0, set to 1 to enable.`fields[]`An array with fields to display. When not specified all fields will be displayed.`sort[]`An array with fields to sort by. The direction of the sort is specified by appending asc or desc to the field, delimited by :. If no direction is specified asc will be used. Example: ?sort\[\]=size&amp;sort\[\]=width:desc is the same as ?sort\[\]=size:asc&amp;sort\[\]=width:desc. If no sort is specified the search backend will rank by relevance.The query is sent in the request body.

### Examples

[](#examples)

**Querying one user**

```
$ curl 'http://imbo/users//images?limit=1&metadata=1' -d '{"foo": "bar"}'
```

**Querying multiple users**

```
$ curl 'http://imbo/images?users[]=&users[]=&limit=1&metadata=1' -d '{"foo": "bar"}'
```

Both these requests results in a response that looks like this:

```
{
  "search": {
    "hits": 3,
    "page": 1,
    "limit": 1,
    "count": 1
  },
  "images": [
    {
      "added": "Mon, 10 Dec 2012 11:57:51 GMT",
      "updated": "Mon, 10 Dec 2012 11:57:51 GMT",
      "checksum": "",
      "originalChecksum": "",
      "extension": "png",
      "size": 6791,
      "width": 1306,
      "height": 77,
      "mime": "image/png",
      "imageIdentifier": "",
      "user": "",
      "metadata": {
        "key": "value",
        "foo": "bar"
      }
    }
  ]
}
```

Imbo DSL
--------

[](#imbo-dsl)

The query language used by Imbo Metadata Search is a subset of the MongoDB query DSL. The query is a JSON-encoded object including `key => value` matches and/or a combination of the supported operators, sent to Imbo in the request body. This section lists all operators and includes a number of examples showing you how to find images using the metadata query.

**Note**: The results of the different queries *might* end up with slightly different results depending on the backend you use the for metadata.

#### Key/value matching

[](#keyvalue-matching)

The simplest form of a metadata query is a simple `key => value` match, where the expressions are AND-ed together if there is more than one key/value match in the query.

```
 {"key":"value","otherkey":"othervalue"}
```

The above search would result in images that have the metadata key `key` set to `value` **and** `otherkey` set to `othervalue`

#### Greater than - `$gt`

[](#greater-than---gt)

This operator can be used to check for values greater than the value specified.

```
{"age":{"$gt":35}}
```

#### Greater than or equal - `$gte`

[](#greater-than-or-equal---gte)

Check for values greater than or equal to the value specified.

```
 {"age":{"$gte":35}}
```

#### Less than - `$lte`

[](#less-than---lte)

Check for values less than to the value specified.

```
{"age":{"$lt":35}}
```

#### Less than or equal - `$lte`

[](#less-than-or-equal---lte)

Check for values less than or equal to the value specified.

```
{"age":{"$lte":35}}
```

#### Not equal - `$ne`

[](#not-equal---ne)

Matches values that are not equal to the value specified.

```
{"name":{"$ne":"christer"}}
```

#### In - `$in`

[](#in---in)

Look for values that appear in the specified set.

```
{"styles":{"$in":["IPA","Imperial Stout","Lambic"]}}
```

#### Not in - `$nin`

[](#not-in---nin)

Look for values that does not appear in the specified set.

```
{"styles":{"$nin":["Pilsner"]}}
```

#### Field exists - `$exists`

[](#field-exists---exists)

Ensure that a given field does or does not exist.

```
{"age":{"$exists":true}}
```

#### Conjunctions - `$and`

[](#conjunctions---and)

This operator can be used to combine a list of criteria that must all match. It takes an array of queries.

```
{"$and": [{"name": {"$in": ["kristoffer", "morten"]}}, {"age": {"$lt": 30}}]}
```

Would find images where the key `name` is either `kristoffer` or `morten` and where the `age` key is less than `30`.

#### Disjunction - `$or`

[](#disjunction---or)

This operator can be used to combine a list of criteria where at least one must match. It takes an array of queries.

```
{"$or":[{"key":"value"},{"otherkey":"othervalue"}]}
```

Would fetch images that have a key named `key` with the value `value` and/or a key named `otherkey` which has the value of `othervalue`.

#### Using several operators in one query

[](#using-several-operators-in-one-query)

All the above operators can be combined into one query. Consider a collection of images of beers which have all been tagged with the name of the brewery, the name of the beer, the style of the beer and the ABV. If we wanted to find all images of beers within a set of styles, above a specific ABV, from two different breweries, and all images of beers from Nøgne Ø, regardless of style and ABV, but not beers called Wit, regardless of brewery, style or ABV, the query could look like this (formatted for easier reading):

```
{
    "name":
    {
        "$ne": "Wit"
    },
    "$or":
    [
        {
            "brewery": "Nøgne Ø"
        },

        {
            "$and":
            [
                {
                    "abv":
                    {
                        "$gte": 5.5
                    }
                },

                {
                    "style":
                    {
                        "$in":
                        [
                            "IPA",
                            "Imperial Stout"
                        ]
                    }
                },

                {
                    "brewery":
                    {
                        "$in":
                        [
                            "HaandBryggeriet",
                            "Ægir"
                        ]
                    }
                }
            ]
        }
    ]
}
```

Keep in mind that large complex queries against large image collections can take a while to finish, and might cause performance issues on the Imbo server(s).

License
=======

[](#license)

Copyright (c) 2015, [Kristoffer Brabrand](mailto:kristoffer@brabrand.no) and [Morten Fangel](mailto:fangel@sevengoslings.net)

Licensed under the MIT License

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 70.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Recently: every ~52 days

Total

8

Last Release

3654d ago

Major Versions

0.1.1 → 1.0.02015-10-14

1.0.0 → 2.0.02015-10-15

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

2.1.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dc712d46ad616603b6d7c1be04809a6789935c6cf7c99e9f1e891ac2045f7a5?d=identicon)[kbrabrand](/maintainers/kbrabrand)

---

Top Contributors

[![kbrabrand](https://avatars.githubusercontent.com/u/2884292?v=4)](https://github.com/kbrabrand "kbrabrand (164 commits)")[![fangel](https://avatars.githubusercontent.com/u/19275?v=4)](https://github.com/fangel "fangel (42 commits)")[![rexxars](https://avatars.githubusercontent.com/u/48200?v=4)](https://github.com/rexxars "rexxars (21 commits)")[![christeredvartsen](https://avatars.githubusercontent.com/u/25402?v=4)](https://github.com/christeredvartsen "christeredvartsen (5 commits)")[![sgulseth](https://avatars.githubusercontent.com/u/1627633?v=4)](https://github.com/sgulseth "sgulseth (2 commits)")

---

Tags

elasticsearchimbometadata-searchphpsearchmetadataimbo

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/imbo-imbo-metadata-search/health.svg)

```
[![Health](https://phpackages.com/badges/imbo-imbo-metadata-search/health.svg)](https://phpackages.com/packages/imbo-imbo-metadata-search)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[solarium/solarium

PHP Solr client

93532.7M98](/packages/solarium-solarium)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
