'Search multi field with term query

I have some documents in a index..

"hits" : [
      {
        "_index" : "siem-referencedata-table-table2d526444eff99b1706053853ef7",
        "_type" : "_doc",
        "_id" : "0table222cc244b04b59d9ecafb0476e6",
        "_score" : 1.0,
        "_source" : {
          "column-name1" : "10.1.10.1",
          "column-name2" : "range(100,200)",
          "column-name3" : "nam3",
          "create_time" : "2022-05-21 03:30:39",
          "last_seen" : "2022-05-21 03:30:39",
          "id" : "0table222cc244b04b59d9ecafb0476e6"
        }
      },...

I want to search documents with three fields column-name1, column-name2 and column-name3. I use below query with term to search exact considered word:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "column-name1": {"value":"10.1.10.1"}
          }
        },
        {
          "term": {
            "column-name2": {"value":"range(100,200)"}
          }
        },
        {
          "term": {
            "column-name3": {"value":"nam3"}
          }
        }
      ]
    }
  }
}

It works without "column-name2": {"value":"range(100,200)"}.. what should I do with range ability? Is there another way to handle this?



Solution 1:[1]

the error states page in load functions has been replaced by url and params a quick search in the documentation as noted here

yields this snippet

export async function load({ params, fetch, session, stuff }) {
    const url = `/blog/${params.slug}.json`;
    const res = await fetch(url);

    if (res.ok) {
        return {
            props: {
                article: await res.json()
            }
        };
    }

    return {
        status: res.status,
        error: new Error(`Could not load ${url}`)
    };
}

you can directly use the params within load()

you can refactor your code to

<script context="module">
    export async function load({params}) {
        const id = params.id;
        const url = `https://pokeapi.co/api/v2/pokemon/${id}`;
        const res = await fetch(url);
        const pokeman = await res.json();
        return {props: {pokeman}};
    }
</script>
<script>
    export let pokeman;
</script>
<h1>{pokeman.name}</h1>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OmG3r