Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

18.2 KB
Raw Blame
---
setup:
  - do:
      indices.create:
        index:  test
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              keyword:
                type: keyword

  - do:
      index:
        index:   test
        id:      "1"
        refresh: true
        body:
          keyword: [ "a", "b" ]

---
fetch fields:
  - requires:
      cluster_features: "gte_v8.15.0"
      reason: _ignored is returned only from 8.15 on

  - do:
      search:
        index: test
        body:
          _source: false
          profile: true
          fields: [keyword]

  - is_true: hits.hits.0._id
  - match: { hits.hits.0.fields.keyword.0: a }
  - match: { hits.hits.0.fields.keyword.1: b }
  - gt: { profile.shards.0.fetch.time_in_nanos: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields: 0 }
  - match: { profile.shards.0.fetch.debug.stored_fields: [_id, _routing, _source] }
  - length: { profile.shards.0.fetch.children: 2 }
  - match: { profile.shards.0.fetch.children.0.type: FetchFieldsPhase }
  - gt: { profile.shards.0.fetch.children.0.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.0.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.children.0.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.0.breakdown.next_reader: 0 }
  - match: { profile.shards.0.fetch.children.1.type: StoredFieldsPhase }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }

---
fetch source:
  - requires:
      cluster_features: "gte_v8.15.0"
      reason: _ignored is returned only from 8.15 on

  - do:
      search:
        index: test
        body:
          profile: true

  - is_true: hits.hits.0._id
  - match: { hits.hits.0._source.keyword.0: a }
  - match: { hits.hits.0._source.keyword.1: b }
  - gt: { profile.shards.0.fetch.time_in_nanos: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields: 0 }
  - match: { profile.shards.0.fetch.debug.stored_fields: [_id, _routing, _source] }
  - length: { profile.shards.0.fetch.children: 3 }
  - match: { profile.shards.0.fetch.children.0.type: FetchFieldsPhase }
  - match: { profile.shards.0.fetch.children.1.type: FetchSourcePhase }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }
  - match: { profile.shards.0.fetch.children.1.debug.fast_path: 1 }
  - match: { profile.shards.0.fetch.children.2.type: StoredFieldsPhase }

---
fetch nested source:
  - requires:
      cluster_features: "gte_v8.15.0"
      reason: _ignored is returned only from 8.15 on

  - do:
      indices.create:
        index:  test_nested
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              keyword:
                type: keyword
              nested:
                type: nested
                properties:
                  text:
                    type: text

  - do:
      index:
        index:   test_nested
        id:      "1"
        refresh: true
        body:
          keyword: [ "a", "b" ]
          nested:
            - text: the quick brown fox
            - text: jumped over the
            - text: lazy dog

  - do:
      search:
        index: test_nested
        body:
          profile: true
          query:
            nested:
              path: nested
              query:
                match_all: {}
              inner_hits: {}

  - is_true: hits.hits.0._id
  - match: { hits.hits.0._source.keyword.0: a }
  - match: { hits.hits.0._source.keyword.1: b }
  - gt: { profile.shards.0.fetch.time_in_nanos: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields_count: 0 }
  - gt: { profile.shards.0.fetch.breakdown.load_stored_fields: 0 }
  - match: { profile.shards.0.fetch.debug.stored_fields: [_id, _routing, _source] }
  - length: { profile.shards.0.fetch.children: 4 }
  - match: { profile.shards.0.fetch.children.0.type: FetchFieldsPhase }
  - match: { profile.shards.0.fetch.children.1.type: FetchSourcePhase }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.1.breakdown.next_reader: 0 }
  - match: { profile.shards.0.fetch.children.2.type: InnerHitsPhase }
  - gt: { profile.shards.0.fetch.children.2.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.2.breakdown.next_reader: 0 }
  - gt: { profile.shards.0.fetch.children.2.breakdown.next_reader_count: 0 }
  - gt: { profile.shards.0.fetch.children.2.breakdown.next_reader: 0 }
  - match: { profile.shards.0.fetch.children.3.type: StoredFieldsPhase }

---
disabling stored fields removes fetch sub phases:
  - requires:
      cluster_features: "gte_v7.16.0"
      reason: fetch profiling implemented in 7.16.0

  - do:
      search:
        index: test
        body:
          stored_fields: _none_
          profile: true

  - match: { hits.hits.0._index: test }
  - match: { profile.shards.0.fetch.debug.stored_fields: [] }
  - is_false: profile.shards.0.fetch.children

---
dfs knn vector profiling:
  - requires:
      cluster_features: "search.default_disk_bbq"
      reason: default to bbq_disk adjusts output

  - do:
      indices.create:
        index: images
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              image:
                type: "dense_vector"
                dims: 3
                index: true
                similarity: "l2_norm"

  - do:
      index:
        index: images
        id: "1"
        refresh: true
        body:
          image: [1, 5, -20]

  - do:
      search:
        index: images
        body:
          profile: true
          knn:
            field: "image"
            query_vector: [-5, 9, -12]
            k: 1
            num_candidates: 100

  - match: { hits.total.value: 1 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.time_in_nanos: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.set_min_competitive_score_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.set_min_competitive_score: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.match_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.match: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.shallow_advance_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.shallow_advance: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.next_doc_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.next_doc: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.score_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.score: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.compute_max_score_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.compute_max_score: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.build_scorer_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.build_scorer: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.rewrite_time: 0 }
  - match: { profile.shards.0.dfs.knn.0.collector.0.reason: "search_top_hits" }
  - gt: { profile.shards.0.dfs.knn.0.collector.0.time_in_nanos: 0 }

---
dfs knn vector profiling description:
  - requires:
      cluster_features: ["lucene_10_4_upgrade"]
      reason: "the profile description changed with Lucene 10.4"
  - do:
      indices.create:
        index: images
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              image:
                type: "dense_vector"
                dims: 3
                index: true
                similarity: "l2_norm"

  - do:
      index:
        index: images
        id: "1"
        refresh: true
        body:
          image: [1, 5, -20]

  - do:
      search:
        index: images
        body:
          profile: true
          knn:
            field: "image"
            query_vector: [-5, 9, -12]
            k: 1
            num_candidates: 100

  - match: { hits.total.value: 1 }
  - is_true: profile.shards.0.dfs.knn.0.query.0.description

---
dfs knn vector profiling collector name:
  - requires:
      cluster_features: "lucene_10_1_upgrade"
      reason: collector name changed with lucene 10.1

  - do:
      indices.create:
        index: images
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              image:
                type: "dense_vector"
                dims: 3
                index: true
                similarity: "l2_norm"

  - do:
      index:
        index: images
        id: "1"
        refresh: true
        body:
          image: [1, 5, -20]

  - do:
      search:
        index: images
        body:
          profile: true
          knn:
            field: "image"
            query_vector: [-5, 9, -12]
            k: 1
            num_candidates: 100

  - match: { profile.shards.0.dfs.knn.0.collector.0.name: "TopScoreDocCollector" }

---
dfs knn vector profiling with vector_operations_count:
  - requires:
      cluster_features: "search.default_disk_bbq"
      reason: default to bbq_disk adjusts output

  - do:
      indices.create:
        index: images
        body:
          settings:
            index.number_of_shards: 1
          mappings:
            properties:
              image:
                type: "dense_vector"
                dims: 3
                index: true
                similarity: "l2_norm"

  - do:
      index:
        index: images
        id: "1"
        refresh: true
        body:
          image: [1, 5, -20]

  - do:
      search:
        index: images
        body:
          profile: true
          knn:
            field: "image"
            query_vector: [-5, 9, -12]
            k: 1
            num_candidates: 100

  - match: { hits.total.value: 1 }
  - gt: { profile.shards.0.dfs.knn.0.vector_operations_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.time_in_nanos: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.set_min_competitive_score_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.set_min_competitive_score: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.match_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.match: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.shallow_advance_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.shallow_advance: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.next_doc_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.next_doc: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.score_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.score: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.compute_max_score_count: 0 }
  - match: { profile.shards.0.dfs.knn.0.query.0.breakdown.compute_max_score: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.build_scorer_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.build_scorer: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight: 0 }
  - gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight_count: 0 }
  - gt: { profile.shards.0.dfs.knn.0.rewrite_time: 0 }
  - match: { profile.shards.0.dfs.knn.0.collector.0.reason: "search_top_hits" }
  - gt: { profile.shards.0.dfs.knn.0.collector.0.time_in_nanos: 0 }

---
dfs profile for search with dfs_query_then_fetch:
  - requires:
      cluster_features: "gte_v8.6.0"
      reason: dfs profiling implemented in 8.6.0

  - do:
      indices.create:
        index: keywords
        body:
          settings:
            index.number_of_shards: 2
          mappings:
            properties:
              keyword:
                type: "keyword"

  - do:
      indices.refresh:
        index: keywords

  # test with no indexed documents
  # expect both shards to have dfs profiles
  - do:
      search:
        index: keywords
        search_type: dfs_query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "a"

  - match: { hits.total.value: 0 }
  - match: { profile.shards.0.dfs.statistics.type: "statistics" }
  - match: { profile.shards.0.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.0.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.0.dfs.statistics.breakdown
  - match: { profile.shards.1.dfs.statistics.type: "statistics" }
  - match: { profile.shards.1.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.1.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.1.dfs.statistics.breakdown

  # expect no shards to have dfs profiles
  - do:
      search:
        index: keywords
        search_type: query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "a"

  - match: { hits.total.value: 0 }
  - is_false: profile.shards.0.dfs

  # test with two indexed documents
  - do:
      index:
        index: keywords
        id: "1"
        refresh: true
        body:
          keyword: "a"

  - do:
      index:
        index: keywords
        id: "2"
        refresh: true
        body:
          keyword: "b"

  # expect both shards to have dfs profiles
  - do:
      search:
        index: keywords
        search_type: dfs_query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "a"

  - match: { hits.total.value: 1 }
  - match: { profile.shards.0.dfs.statistics.type: "statistics" }
  - match: { profile.shards.0.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.0.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.0.dfs.statistics.breakdown
  - match: { profile.shards.1.dfs.statistics.type: "statistics" }
  - match: { profile.shards.1.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.1.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.1.dfs.statistics.breakdown

  - do:
      search:
        index: keywords
        search_type: dfs_query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "b"

  - match: { hits.total.value: 1 }
  - match: { profile.shards.0.dfs.statistics.type: "statistics" }
  - match: { profile.shards.0.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.0.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.0.dfs.statistics.breakdown
  - match: { profile.shards.1.dfs.statistics.type: "statistics" }
  - match: { profile.shards.1.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.1.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.1.dfs.statistics.breakdown

  - do:
      search:
        index: keywords
        search_type: dfs_query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "c"

  - match: { hits.total.value: 0 }
  - match: { profile.shards.0.dfs.statistics.type: "statistics" }
  - match: { profile.shards.0.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.0.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.0.dfs.statistics.breakdown
  - match: { profile.shards.1.dfs.statistics.type: "statistics" }
  - match: { profile.shards.1.dfs.statistics.description: "collect term statistics" }
  - gte: { profile.shards.1.dfs.statistics.time_in_nanos: 0 }
  - is_true: profile.shards.1.dfs.statistics.breakdown

  # expect no shards to have dfs profiles
  - do:
      search:
        index: keywords
        search_type: query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "a"

  - match: { hits.total.value: 1 }
  - is_false: profile.shards.0.dfs

  - do:
      search:
        index: keywords
        search_type: query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "b"

  - match: { hits.total.value: 1 }
  - is_false: profile.shards.0.dfs

  - do:
      search:
        index: keywords
        search_type: query_then_fetch
        body:
          profile: true
          query:
            term:
              keyword: "c"

  - match: { hits.total.value: 0 }
  - is_false: profile.shards.0.dfs
---
composite_id_parsed:
  - requires:
      cluster_features: ["gte_v8.10.0"]
      reason: node_id, shard_id, index and cluster fields added in 8.10.0
      test_runner_features: "contains"

  - do:
      search:
        index: test
        body:
          _source: false
          profile: true
          fields: [keyword]
  - set:  { profile.shards.0.id: composite_id,
            profile.shards.0.node_id: first_node_id,
            profile.shards.0.index: first_index
          }

  - is_true: profile.shards.0.id
  - is_true: profile.shards.0.node_id
  - length: { profile.shards.0.node_id: 22 }
  - gte: { profile.shards.0.shard_id: 0 }
  - match: { profile.shards.0.index: "test" }
  - is_true: profile.shards.0.cluster
  - contains: { $composite_id: $first_node_id }
  - contains: { $composite_id: $first_index }