{
  "schema_version": 2,
  "id": "develop/ai/search-and-query/query/range",
  "title": "Range queries",
  "url": "https://redis.io/docs/latest/develop/ai/search-and-query/query/range/",
  "summary": "Perform numeric range queries",
  "aliases": [
    "/develop/interact/search-and-query/query/range"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-11T15:33:04+01:00",
  "page_type": "content",
  "content_hash": "103966df3a5bb7b415e6a365a0e49065e903743cdb71d0ffd9968d9237b2964f",
  "sections": [
    {
      "id": "start-and-end-values",
      "title": "Start and end values",
      "role": "content",
      "text": "Start and end values are by default inclusive, but you can prepend `(` to a value to exclude it from the range.\n\nThe values `-inf`, `inf`, and `+inf` are valid values that allow you to define open ranges."
    },
    {
      "id": "result-set",
      "title": "Result set",
      "role": "returns",
      "text": "An open-range query can lead to a large result set. \n\nBy default, [`FT.SEARCH`](https://redis.io/docs/latest/commands/ft.search) returns only the first ten results. The `LIMIT` argument helps you to scroll through the result set. The `SORTBY` argument ensures that the documents in the result set are returned in the specified order.\n\n[code example]\n\nYou can find further details about using the `LIMIT` and `SORTBY` in the [[`FT.SEARCH`](https://redis.io/docs/latest/commands/ft.search) command reference](https://redis.io/docs/latest/commands/ft.search)."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "The examples in this section use a schema with the following fields:\n\n| Field name | Field type |\n| ---------- | ---------- |\n| `price` | `NUMERIC` |\n\nThe following query finds bicycles within a price range greater than or equal to 500 USD and smaller than or equal to 1000 USD (`500 <= price <= 1000`):\n\nFoundational: Query numeric fields with inclusive range syntax when you need to find documents with values between two bounds\n\n**Difficulty:** Beginner\n\n**Commands:** FT.SEARCH\n\n**Complexity:**\n- FT.SEARCH: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nThis is semantically equivalent to:\n\nFoundational: Query numeric fields using a FILTER clause when you need an alternative syntax for range queries with different query execution semantics\n\n**Difficulty:** Beginner\n\n**Commands:** FT.SEARCH\n\n**Complexity:**\n- FT.SEARCH: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nFor bicycles with a price greater than 1000 USD (`price > 1000`), you can use:\n\nOpen ranges: Query numeric fields with open ranges using infinity notation and exclusive bounds when you need to find documents above or below a threshold\n\n**Difficulty:** Intermediate\n\n**Commands:** FT.SEARCH\n\n**Complexity:**\n- FT.SEARCH: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]\n\n\n\nThe example below returns bicycles with a price lower than or equal to 2000 USD (`price <= 2000`) by returning the five cheapest bikes:\n\nSorting and pagination: Combine range queries with SORTBY and LIMIT to retrieve sorted results in pages when you need to handle large result sets efficiently\n\n**Difficulty:** Intermediate\n\n**Commands:** FT.SEARCH\n\n**Complexity:**\n- FT.SEARCH: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), Python\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Python\n\n[code example]"
    },
    {
      "id": "non-numeric-range-queries",
      "title": "Non-numeric range queries",
      "role": "content",
      "text": "You can learn more about non-numeric range queries, such as [geospatial](https://redis.io/docs/latest/develop/ai/search-and-query/query/geo-spatial) or [vector search](https://redis.io/docs/latest/develop/ai/search-and-query/query/vector-search) queries, in their dedicated articles."
    }
  ],
  "examples": [
    {
      "id": "result-set-ex0",
      "language": "plaintext",
      "code": "FT.SEARCH index \"@field:[start end]\" SORTBY field LIMIT page_start page_end",
      "section_id": "result-set"
    },
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> FT.SEARCH idx:bicycle \"@price:[500 1000]\"\n1) (integer) 3\n2) \"bicycle:2\"\n3) 1) \"$\"\n   2) \"{\\\"pickup_zone\\\":\\\"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, -87.6848 41.8231, -87.6848 41.9331))\\\",\\\"store_location\\\":\\\"-87.6298,41.8781\\\",\\\"brand\\\":\\\"Nord\\\",\\\"model\\\":\\\"Chook air 5\\\",\\\"price\\\":815,\\\"description\\\":\\\"The Chook Air 5  gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. The lower  top tube makes it easy to mount and dismount in any situation, giving your kids greater safety on the trails.\\\",\\\"condition\\\":\\\"used\\\"}\"\n4) \"bicycle:5\"\n... output truncated for AI-facing Markdown ...\n7) 1) \"$\"\n   2) \"{\\\"pickup_zone\\\":\\\"POLYGON((12.4464 42.1028, 12.5464 42.1028, 12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\\\",\\\"store_location\\\":\\\"12.4964,41.9028\\\",\\\"model\\\":\\\"ThrillCycle\\\",\\\"brand\\\":\\\"BikeShind\\\",\\\"price\\\":815,\\\"description\\\":\\\"An artsy,  retro-inspired bicycle that\\xe2\\x80\\x99s as functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. A 9-speed drivetrain has enough gears for coasting in the city, but we wouldn\\xe2\\x80\\x99t suggest taking it to the mountains. Fenders protect you from mud, and a rear basket lets you transport groceries, flowers and books. The ThrillCycle comes with a limited lifetime warranty, so this little guy will last you long past graduation.\\\",\\\"condition\\\":\\\"refurbished\\\"}\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "csharp",
      "code": "SearchResult res1 = db.FT().Search(\n            \"idx:bicycle\",\n            new(\"@price:[500 1000]\")\n        );\n        Console.WriteLine(res1.TotalResults);   // >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "go",
      "code": "res1, err := rdb.FTSearchWithArgs(ctx,\n\t\t\"idx:bicycle\", \"@price:[500 1000]\",\n\t\t&redis.FTSearchOptions{\n\t\t\tReturn: []redis.FTSearchReturn{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tSortBy: []redis.FTSearchSortBy{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tAsc:       true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1.Total) // >>> 3\n\n\tfor _, doc := range res1.Docs {\n\t\tfmt.Printf(\"%v : price %v\\n\", doc.ID, doc.Fields[\"price\"])\n\t}\n\t// >>> bicycle:2 : price 815\n\t// >>> bicycle:5 : price 810\n\t// >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "java",
      "code": "CompletableFuture<SearchReply<String, String>> priceResults = asyncCommands\n                    .ftSearch(\"idx:bicycle\", \"@price:[500 1000]\").thenApply(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s\\n\", doc.getId());\n                        });\n                        // >>> ID: bicycle:2\n                        // >>> ID: bicycle:5\n                        // >>> ID: bicycle:9\n                        return res;\n                    }).toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Mono<SearchReply<String, String>> priceResults = reactiveCommands.ftSearch(\"idx:bicycle\", \"@price:[500 1000]\")\n                    .doOnNext(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s\\n\", doc.getId());\n                        });\n                        // >>> ID: bicycle:2\n                        // >>> ID: bicycle:5\n                        // >>> ID: bicycle:9\n                    });",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "SearchResult res1 = jedis.ftSearch(\n            \"idx:bicycle\", \"@price:[500 1000]\",\n            FTSearchParams.searchParams().returnFields(\"price\"));\n        System.out.println(res1.getTotalResults()); // >>> 3\n\n        List<Document> docs1 = res1.getDocuments();\n\n        for (Document document : docs1) {\n            System.out.println(document.getId() + \" : price \" + document.getString(\"price\"));\n        }\n        // >>> bicycle:2 : price 815\n        // >>> bicycle:5 : price 810\n        // >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "javascript",
      "code": "const res1 = await client.ft.search('idx:bicycle', '@price:[500 1000]');\nconsole.log(res1.total); // >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "python",
      "code": "res = index.search(Query(\"@price:[500 1000]\"))\nprint(res.total)\n# >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "plaintext",
      "code": "> FT.SEARCH idx:bicycle \"*\" FILTER price 500 1000\n1) (integer) 3\n2) \"bicycle:2\"\n3) 1) \"$\"\n   2) \"{\\\"pickup_zone\\\":\\\"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, -87.6848 41.8231, -87.6848 41.9331))\\\",\\\"store_location\\\":\\\"-87.6298,41.8781\\\",\\\"brand\\\":\\\"Nord\\\",\\\"model\\\":\\\"Chook air 5\\\",\\\"price\\\":815,\\\"description\\\":\\\"The Chook Air 5  gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. The lower  top tube makes it easy to mount and dismount in any situation, giving your kids greater safety on the trails.\\\",\\\"condition\\\":\\\"used\\\"}\"\n4) \"bicycle:5\"\n... output truncated for AI-facing Markdown ...\n7) 1) \"$\"\n   2) \"{\\\"pickup_zone\\\":\\\"POLYGON((12.4464 42.1028, 12.5464 42.1028, 12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\\\",\\\"store_location\\\":\\\"12.4964,41.9028\\\",\\\"model\\\":\\\"ThrillCycle\\\",\\\"brand\\\":\\\"BikeShind\\\",\\\"price\\\":815,\\\"description\\\":\\\"An artsy,  retro-inspired bicycle that\\xe2\\x80\\x99s as functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. A 9-speed drivetrain has enough gears for coasting in the city, but we wouldn\\xe2\\x80\\x99t suggest taking it to the mountains. Fenders protect you from mud, and a rear basket lets you transport groceries, flowers and books. The ThrillCycle comes with a limited lifetime warranty, so this little guy will last you long past graduation.\\\",\\\"condition\\\":\\\"refurbished\\\"}\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "csharp",
      "code": "SearchResult res2 = db.FT().Search(\n            \"idx:bicycle\",\n            new Query().AddFilter(\n                new Query.NumericFilter(\"price\", 500, 1000)\n            )\n        );\n        Console.WriteLine(res2.TotalResults);   // >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "go",
      "code": "res2, err := rdb.FTSearchWithArgs(ctx,\n\t\t\"idx:bicycle\", \"*\",\n\t\t&redis.FTSearchOptions{\n\t\t\tFilters: []redis.FTSearchFilter{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tMin:       500,\n\t\t\t\t\tMax:       1000,\n\t\t\t\t},\n\t\t\t},\n\t\t\tReturn: []redis.FTSearchReturn{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tSortBy: []redis.FTSearchSortBy{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tAsc:       true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2.Total) // >>> 3\n\n\tfor _, doc := range res2.Docs {\n\t\tfmt.Printf(\"%v : price %v\\n\", doc.ID, doc.Fields[\"price\"])\n\t}\n\t// >>> bicycle:2 : price 815\n\t// >>> bicycle:5 : price 810\n\t// >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "java",
      "code": "// `Filter` is not supported.",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "java",
      "code": "// `Filter` is not supported.",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "java",
      "code": "SearchResult res2 = jedis.ftSearch(\"idx:bicycle\",\n            \"*\",\n            FTSearchParams.searchParams()\n                .returnFields(\"price\")\n                .filter(\"price\", 500, 1000)\n        );\n        System.out.println(res2.getTotalResults()); // >>> 3\n\n        List<Document> docs2 = res2.getDocuments();\n\n        for (Document document : docs2) {\n            System.out.println(document.getId() + \" : price \" + document.getString(\"price\"));\n        }\n        // >>> bicycle:2 : price 815\n        // >>> bicycle:5 : price 810\n        // >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "javascript",
      "code": "// FILTER is not supported\n// const res2 = await client.ft.search('idx:bicycle', '*', {\n//   FILTER: {\n//     field: 'price',\n//     min: 500,\n//     max: 1000,\n//   }\n// });\n// console.log(res2.total); // >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex15",
      "language": "python",
      "code": "query = Query(\"*\").add_filter(NumericFilter(\"price\", 500, 1000))\nres = index.search(query)\nprint(res.total)\n# >>> 3",
      "section_id": "examples"
    },
    {
      "id": "examples-ex16",
      "language": "plaintext",
      "code": "> FT.SEARCH idx:bicycle \"@price:[(1000 +inf]\"\n 1) (integer) 5\n 2) \"bicycle:1\"\n 3) 1) \"$\"\n    2) \"{\\\"pickup_zone\\\":\\\"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, -118.2887 33.9872, -118.2887 34.0972))\\\",\\\"store_location\\\":\\\"-118.2437,34.0522\\\",\\\"brand\\\":\\\"Bicyk\\\",\\\"model\\\":\\\"Hillcraft\\\",\\\"price\\\":1200,\\\"description\\\":\\\"Kids want to ride with as little weight as possible. Especially on an incline! They may be at the age when a 27.5\\\\\\\" wheel bike is just too clumsy coming off a 24\\\\\\\" bike. The Hillcraft 26 is just the solution they need!\\\",\\\"condition\\\":\\\"used\\\"}\"\n 4) \"bicycle:4\"\n... output truncated for AI-facing Markdown ...\n    2) \"{\\\"pickup_zone\\\":\\\"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, 1.9450 41.1987, 1.9450 41.4301))\\\",\\\"store_location\\\":\\\"2.1734, 41.3851\\\",\\\"brand\\\":\\\"nHill\\\",\\\"model\\\":\\\"Summit\\\",\\\"price\\\":1200,\\\"description\\\":\\\"This budget mountain bike from nHill performs well both on bike paths and on the trail. The fork with 100mm of travel absorbs rough terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. The Shimano Tourney drivetrain offered enough gears for finding a comfortable pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. Whether you want an affordable bike that you can take to work, but also take trail in mountains on the weekends or you\\xe2\\x80\\x99re just after a stable, comfortable ride for the bike path, the Summit gives a good value for money.\\\",\\\"condition\\\":\\\"new\\\"}\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex17",
      "language": "csharp",
      "code": "SearchResult res3 = db.FT().Search(\n            \"idx:bicycle\",\n            new Query(\"*\").AddFilter(new Query.NumericFilter(\n                    \"price\", 1000, true, Double.PositiveInfinity, false\n                )\n            )\n        );\n        Console.WriteLine(res3.TotalResults);   // >>> 5",
      "section_id": "examples"
    },
    {
      "id": "examples-ex18",
      "language": "go",
      "code": "res3, err := rdb.FTSearchWithArgs(ctx,\n\t\t\"idx:bicycle\", \"*\",\n\t\t&redis.FTSearchOptions{\n\t\t\tReturn: []redis.FTSearchReturn{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tSortBy: []redis.FTSearchSortBy{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tAsc:       true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tFilters: []redis.FTSearchFilter{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tMin:       \"(1000\",\n\t\t\t\t\tMax:       \"+inf\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3.Total) // >>> 5\n\n\tfor _, doc := range res3.Docs {\n\t\tfmt.Printf(\"%v : price %v\\n\", doc.ID, doc.Fields[\"price\"])\n\t}\n\t// >>> bicycle:1 : price 1200\n\t// >>> bicycle:4 : price 3200\n\t// >>> bicycle:6 : price 2300\n\t// >>> bicycle:3 : price 3400\n\t// >>> bicycle:8 : price 1200",
      "section_id": "examples"
    },
    {
      "id": "examples-ex19",
      "language": "java",
      "code": "SearchArgs<String, String> priceSearchArgs2 = SearchArgs.<String, String> builder().returnField(\"price\").build();\n\n            CompletableFuture<SearchReply<String, String>> priceResults2 = asyncCommands\n                    .ftSearch(\"idx:bicycle\", \"@price:[(1000 +inf]\", priceSearchArgs2).thenApply(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s, price: %s\\n\", doc.getId(), doc.getFields().get(\"price\"));\n                        });\n                        // >>> ID: bicycle:1, price: 1200\n                        // >>> ID: bicycle:3, price: 3400\n                        // >>> ID: bicycle:4, price: 3200\n                        // >>> ID: bicycle:6, price: 2300\n                        // >>> ID: bicycle:8, price: 1200\n                        return res;\n                    }).toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex20",
      "language": "java",
      "code": "SearchArgs<String, String> priceSearchArgs2 = SearchArgs.<String, String> builder().returnField(\"price\").build();\n\n            Mono<SearchReply<String, String>> priceResults2 = reactiveCommands\n                    .ftSearch(\"idx:bicycle\", \"@price:[(1000 +inf]\", priceSearchArgs2).doOnNext(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s, price: %s\\n\", doc.getId(), doc.getFields().get(\"price\"));\n                        });\n                        // >>> ID: bicycle:1, price: 1200\n                        // >>> ID: bicycle:3, price: 3400\n                        // >>> ID: bicycle:4, price: 3200\n                        // >>> ID: bicycle:6, price: 2300\n                        // >>> ID: bicycle:8, price: 1200\n                    });",
      "section_id": "examples"
    },
    {
      "id": "examples-ex21",
      "language": "java",
      "code": "SearchResult res3 = jedis.ftSearch(\"idx:bicycle\",\n            \"*\",\n            FTSearchParams.searchParams()\n                .returnFields(\"price\")\n                .filter(\"price\", 1000, true, Double.POSITIVE_INFINITY, false)\n        );\n        System.out.println(res3.getTotalResults()); // >>> 5\n\n        List<Document> docs3 = res3.getDocuments();\n\n        for (Document document : docs3) {\n            System.out.println(document.getId() + \" : price \" + document.getString(\"price\"));\n        }\n        // >>> bicycle:1 : price 1200\n        // >>> bicycle:4 : price 3200\n        // >>> bicycle:6 : price 2300\n        // >>> bicycle:3 : price 3400\n        // >>> bicycle:8 : price 1200",
      "section_id": "examples"
    },
    {
      "id": "examples-ex22",
      "language": "javascript",
      "code": "// FILTER is not supported\n// const res3 = await client.ft.search('idx:bicycle', '*', {\n//   FILTER: {\n//     field: 'price',\n//     min: '(1000',\n//     max: '+inf,\n//   }\n// });\n// console.log(res3.total); // >>> 5",
      "section_id": "examples"
    },
    {
      "id": "examples-ex23",
      "language": "python",
      "code": "query = Query(\"*\").add_filter(NumericFilter(\"price\", \"(1000\", \"+inf\"))\nres = index.search(query)\nprint(res.total)\n# >>> 5",
      "section_id": "examples"
    },
    {
      "id": "examples-ex24",
      "language": "plaintext",
      "code": "> FT.SEARCH idx:bicycle \"@price:[-inf 2000]\" SORTBY price LIMIT 0 5\n 1) (integer) 7\n 2) \"bicycle:0\"\n 3) 1) \"price\"\n    2) \"270\"\n    3) \"$\"\n    4) \"{\\\"pickup_zone\\\":\\\"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, -74.0610 40.6678, -74.0610 40.7578))\\\",\\\"store_location\\\":\\\"-74.0060,40.7128\\\",\\\"brand\\\":\\\"Velorim\\\",\\\"model\\\":\\\"Jigger\\\",\\\"price\\\":270,\\\"description\\\":\\\"Small and powerful, the Jigger is the best ride for the smallest of tikes! This is the tiniest kids\\xe2\\x80\\x99 pedal bike on the market available without a coaster brake, the Jigger is the vehicle of choice for the rare tenacious little rider raring to go.\\\",\\\"condition\\\":\\\"new\\\"}\"\n... output truncated for AI-facing Markdown ...\n    3) \"$\"\n    4) \"{\\\"pickup_zone\\\":\\\"POLYGON((12.4464 42.1028, 12.5464 42.1028, 12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\\\",\\\"store_location\\\":\\\"12.4964,41.9028\\\",\\\"model\\\":\\\"ThrillCycle\\\",\\\"brand\\\":\\\"BikeShind\\\",\\\"price\\\":815,\\\"description\\\":\\\"An artsy,  retro-inspired bicycle that\\xe2\\x80\\x99s as functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. A 9-speed drivetrain has enough gears for coasting in the city, but we wouldn\\xe2\\x80\\x99t suggest taking it to the mountains. Fenders protect you from mud, and a rear basket lets you transport groceries, flowers and books. The ThrillCycle comes with a limited lifetime warranty, so this little guy will last you long past graduation.\\\",\\\"condition\\\":\\\"refurbished\\\"}\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex25",
      "language": "csharp",
      "code": "SearchResult res4 = db.FT().Search(\n            \"idx:bicycle\",\n            new Query(\"@price:[-inf 2000]\")\n                .SetSortBy(\"price\")\n                .Limit(0, 5)\n        );\n        Console.WriteLine(res4.TotalResults);   // >>> 7\n        Console.WriteLine($\"Prices: {string.Join(\", \", res4.Documents.Select(d => d[\"price\"]))}\");\n        // >>> Prices: 270, 430, 810, 815, 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex26",
      "language": "go",
      "code": "res4, err := rdb.FTSearchWithArgs(ctx,\n\t\t\"idx:bicycle\",\n\t\t\"@price:[-inf 2000]\",\n\t\t&redis.FTSearchOptions{\n\t\t\tReturn: []redis.FTSearchReturn{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tSortBy: []redis.FTSearchSortBy{\n\t\t\t\t{\n\t\t\t\t\tFieldName: \"price\",\n\t\t\t\t\tAsc:       true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tLimitOffset: 0,\n\t\t\tLimit:       5,\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res4.Total) // >>> 7\n\n\tfor _, doc := range res4.Docs {\n\t\tfmt.Printf(\"%v : price %v\\n\", doc.ID, doc.Fields[\"price\"])\n\t}\n\t// >>> bicycle:0 : price 270\n\t// >>> bicycle:7 : price 430\n\t// >>> bicycle:5 : price 810\n\t// >>> bicycle:2 : price 815\n\t// >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex27",
      "language": "java",
      "code": "SearchArgs<String, String> priceSearchArgs3 = SearchArgs.<String, String> builder().returnField(\"price\")\n                    .sortBy(SortByArgs.<String> builder().attribute(\"price\").build()).limit(0, 5).build();\n\n            CompletableFuture<SearchReply<String, String>> priceResults3 = asyncCommands\n                    .ftSearch(\"idx:bicycle\", \"@price:[-inf 2000]\", priceSearchArgs3).thenApply(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s, price: %s\\n\", doc.getId(), doc.getFields().get(\"price\"));\n                        });\n                        // >>> ID: bicycle:0, price: 270\n                        // >>> ID: bicycle:2, price: 815\n                        // >>> ID: bicycle:5, price: 810\n                        // >>> ID: bicycle:7, price: 430\n                        // >>> ID: bicycle:9, price: 815\n                        return res;\n                    }).toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex28",
      "language": "java",
      "code": "SearchArgs<String, String> priceSearchArgs3 = SearchArgs.<String, String> builder().returnField(\"price\")\n                    .sortBy(SortByArgs.<String> builder().attribute(\"price\").build()).limit(0, 5).build();\n\n            Mono<SearchReply<String, String>> priceResults3 = reactiveCommands\n                    .ftSearch(\"idx:bicycle\", \"@price:[-inf 2000]\", priceSearchArgs3).doOnNext(res -> {\n                        res.getResults().stream().sorted((doc1, doc2) -> doc1.getId().compareTo(doc2.getId())).forEach(doc -> {\n                            System.out.printf(\"ID: %s, price: %s\\n\", doc.getId(), doc.getFields().get(\"price\"));\n                        });\n                        // >>> ID: bicycle:0, price: 270\n                        // >>> ID: bicycle:2, price: 815\n                        // >>> ID: bicycle:5, price: 810\n                        // >>> ID: bicycle:7, price: 430\n                        // >>> ID: bicycle:9, price: 815\n                    });",
      "section_id": "examples"
    },
    {
      "id": "examples-ex29",
      "language": "java",
      "code": "SearchResult res4 = jedis.ftSearch(\"idx:bicycle\",\n            \"@price:[-inf 2000]\",\n            FTSearchParams.searchParams()\n                    .returnFields(\"price\")\n                    .sortBy(\"price\", SortingOrder.ASC)\n                    .limit(0, 5) \n        );\n        System.out.println(res4.getTotalResults()); // >>> 7\n\n        List<Document> docs4 = res4.getDocuments();\n\n        for (Document document : docs4) {\n            System.out.println(document.getId() + \" : price \" + document.getString(\"price\"));\n        }\n        // >>> bicycle:0 : price 270\n        // >>> bicycle:7 : price 430\n        // >>> bicycle:5 : price 810\n        // >>> bicycle:2 : price 815\n        // >>> bicycle:9 : price 815",
      "section_id": "examples"
    },
    {
      "id": "examples-ex30",
      "language": "javascript",
      "code": "const res4 = await client.ft.search(\n  'idx:bicycle',\n  '@price:[-inf 2000]',\n  {\n    SORTBY: 'price',\n    LIMIT: { from: 0, size: 5 }\n  }\n);\nconsole.log(res4.total); // >>> 7\nconsole.log(res4); // >>> { total: 7, documents: [ { id: 'bicycle:0', value: [Object: null prototype] }, { id: 'bicycle:7', value: [Object: null prototype] }, { id: 'bicycle:5', value: [Object: null prototype] }, { id: 'bicycle:2', value: [Object: null prototype] }, { id: 'bicycle:9', value: [Object: null prototype] } ] }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex31",
      "language": "python",
      "code": "query = Query('@price:[-inf 2000]').sort_by('price').paging(0, 5)\nres = index.search(query)\nprint(res.total)\nprint(res)\n# >>> Result{7 total, docs: [Document {'id': 'bicycle:0', ... }, Document {'id': 'bicycle:7', ... }, Document {'id': 'bicycle:5', ... }, ...]",
      "section_id": "examples"
    }
  ]
}
