docs

a slatepencil documentail site

View on GitHub

Query

example

// You want to see all the items that are (round AND (red OR blue)):
const res = await client.search({
  index: "text-index",
  from: 30,
  size: 10,
  _source: false,
  sort: {
    _score: "desc",
  },
  query: {
    bool: {
      must: [
        {
          term: { shape: "round" },
        },
        {
          bool: {
            should: [{ term: { color: "red" } }, { term: { color: "blue" } }],
          },
        },
      ],
    },
  },
});
const res = client.search({
  index: 'test-policy',
  size: 0,
  from: 10,
  _source: false,
  sort: { _score: 'desc' }
  query: {
    bool: {
      filter: [
        {
          term: {
            isDel: false,
          },
        },
        {
          term: {
            isPublish: true,
          },
        },
      ],
      should: [
        {
          bool: {
            must: [
              {
                term: {
                  isLongTerm: true,
                },
              },
              {
                term: {
                  isPublic: true,
                },
              },
            ],
          },
        },
        {
          bool: {
            must: [
              {
                term: {
                  isLongTerm: false,
                },
              },
              {
                range: {
                  validEnd: {
                    gte: "2024-03-06T15:59:59.999Z",
                  },
                },
              },
              {
                term: {
                  isPublic: true,
                },
              },
            ],
          },
        },
      ],
      must: [
        {
          range: {
            validStart: {
              lte: 1709222400000,
            },
          },
        },
        {
          range: {
            validEnd: {
              gte: 1711814400000,
            },
          },
        },
        {
          bool: {
            should: [
              {
                match: {
                  name: "安亭",
                },
              },
              {
                match: {
                  org: "安亭",
                },
              },
              {
                match: {
                  essential: "安亭",
                },
              },
              {
                match: {
                  code: "安亭",
                },
              },
              {
                match: {
                  category: "安亭",
                },
              },
              {
                match: {
                  scope: "安亭",
                },
              },
              {
                match: {
                  fundSource: "安亭",
                },
              },
              {
                match: {
                  industry: "安亭",
                },
              },
              {
                match: {
                  metric: "安亭",
                },
              },
              {
                match: {
                  interpret: "安亭",
                },
              },
              {
                match: {
                  content: "安亭",
                },
              },
              {
                match: {
                  tagsTxt: "安亭",
                },
              },
            ],
          },
        },
        {
          terms: {
            industryId: [
              "654a3e7ac9be7a002734aaa0",
              "654a3e7ac9be7a002734aaa1",
              "654a3e7ac9be7a002734aaa2",
            ],
          },
        },
        {
          terms: {
            categoryId: [
              "654a3e7ac9be7a002734aa98",
              "654a3e7ac9be7a002734aa99",
              "654a3e7ac9be7a002734aa9e",
              "656555d689c67f0012cdfda6",
            ],
          },
        },
      ],
    },
  },
});