code: def test_lookup_with_filter_by_metadata(ses):
      metadata = dict(tenant_id="foo")
      ses.add_image("test1.jpg", metadata=metadata, refresh_after=True)
  
      metadata2 = dict(tenant_id="bar-2")
      ses.add_image("test2.jpg", metadata=metadata2, refresh_after=True)
  
      r = ses.search_image(
          "test1.jpg",
          pre_filter={
              "term": {"{}.metadata.tenant_id".format(DOC_TYPE): "foo"}
          },
      )
      assert len(r) == 1
      assert r[0]["metadata"] == metadata
  
      r = ses.search_image(
          "test1.jpg",
          pre_filter={
              "term": {
                  "{}.metadata.tenant_id".format(DOC_TYPE): "bar-2"
              }
          },
      )
      assert len(r) == 1
      assert r[0]["metadata"] == metadata2
  
      r = ses.search_image(
          "test1.jpg",
          pre_filter={
              "term": {
                  "{}.metadata.tenant_id".format(DOC_TYPE): "bar-3"
              }
          },
      )
      assert len(r) == 0
  
imports: import pytest
  import os
  import hashlib
  from elasticsearch import Elasticsearch, ConnectionError, RequestError, NotFoundError
  from time import sleep
  from image_match.elasticsearch_driver import SignatureES
  from PIL import Image
label_desc: Use image node_id 18 for calling a global function with example usage: test_lookup_with_filter_by_metadata(ses) without return types