{"id":13595592,"url":"https://github.com/cch123/elastic-rs","last_synced_at":"2025-10-29T04:31:42.371Z","repository":{"id":57623877,"uuid":"166690281","full_name":"cch123/elastic-rs","owner":"cch123","description":"comvert bool expression to elasticsearch DSL in rust","archived":false,"fork":false,"pushed_at":"2023-07-21T00:54:29.000Z","size":37,"stargazers_count":47,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-03T01:24:20.820Z","etag":null,"topics":["boolean-expression","dsl","elastic","elasticsearch","rust","sql"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cch123.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-20T17:40:39.000Z","updated_at":"2024-08-01T16:40:10.499Z","dependencies_parsed_at":"2024-08-01T16:39:57.576Z","dependency_job_id":"7221564c-a572-4a86-bbff-22514b6d928a","html_url":"https://github.com/cch123/elastic-rs","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":"0.022727272727272707","last_synced_commit":"fd3621a4d68b404c2b733320af8c65a752753da1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch123%2Felastic-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch123%2Felastic-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch123%2Felastic-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cch123%2Felastic-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cch123","download_url":"https://codeload.github.com/cch123/elastic-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238768422,"owners_count":19527197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boolean-expression","dsl","elastic","elasticsearch","rust","sql"],"created_at":"2024-08-01T16:01:53.079Z","updated_at":"2025-10-29T04:31:37.088Z","avatar_url":"https://github.com/cch123.png","language":"Rust","funding_links":[],"categories":["Rust","Projects"],"sub_categories":[],"readme":"# Overview\n\nConvert Bool Expression to Elasticsearch DSL.\n\n```\n                                          +----------------------------------------------------+\n                                          |{                                                   |\n                                          |    \"query\": {                                      |\n                                          |        \"bool\": {                                   |\n                                          |            \"must\": [{                              |\n                                          |                \"match\": {                          |\n                                          |                    \"a\": {                          |\n                                          |                        \"query\": \"1\",               |\n                                          |                        \"type\": \"phrase\"            |\n                                          |                    }                               |\n                                          |                }                                   |\n                                          |            }, {                                    |\n                                          |                \"bool\": {                           |\n                                          |                    \"must\": [{                      |\n                                          |                        \"match\": {                  |\n                                          |                            \"b\": {                  |\n+-----------------------------+           |                                \"query\": \"2\",       |\n|a = 1 and (b = 2 and (c = 3))|----------\u003e|                                \"type\": \"phrase\"    |\n+-----------------------------+           |                            }                       |\n                                          |                        }                           |\n                                          |                    }, {                            |\n                                          |                        \"match\": {                  |\n                                          |                            \"c\": {                  |\n                                          |                                \"query\": \"3\",       |\n                                          |                                \"type\": \"phrase\"    |\n                                          |                            }                       |\n                                          |                        }                           |\n                                          |                    }]                              |\n                                          |                }                                   |\n                                          |            }]                                      |\n                                          |        }                                           |\n                                          |    }                                               |\n                                          |}                                                   |\n                                          +----------------------------------------------------+\n```\n\nExample:\n\nAdd:\n\n```toml\n[dependencies]\nelastic_query = \"0.4.4\"\n```\n\nTo your `Cargo.toml`, then use as follows:\n\n```rust\nextern crate elastic_query;\n\nfn main() {\n    let result = elastic_query::convert(\"a = 1 and b in (1,2,3)\".to_string(), 0, 100, vec![], vec![]).unwrap();\n    println!(\"{}\", result);\n}\n\n```\n\nGrammar:\n\n```peg\nbool_expr = { SOI ~ expr ~ EOI }\n\nexpr = {\n    (paren_bool | comp_expr) ~ ( (and_op|or_op)~ (paren_bool| comp_expr))*\n}\n\nand_op = { \"and\" }\nor_op = { \"or\" }\n\nparen_bool = { \"(\" ~ expr ~  \")\" }\n\ncomp_expr = { field ~ op ~ value }\n\nfield = @{ (ASCII_ALPHA ~ ASCII_ALPHANUMERIC*) }\nop = { eq | neq | op_in | op_not_in | gt | gte | lt | lte | like | not_like }\neq = { \"=\" }\nneq = { \"!=\" | \"\u003c\u003e\"}\nop_in = { \"in\" }\nop_not_in= { \"not\" ~ \"in\"}\ngt = { \"\u003e\" }\ngte = { \"\u003e=\" }\nlt = { \"\u003c\" }\nlte = { \"\u003c=\" }\nlike = { \"like\" }\nnot_like = { \"not\" ~ \"like\" }\n\nvalue = {\n    string_literal\n    | num_literal\n    | \"(\" ~ string_literal ~(\",\" ~ string_literal)* ~ \")\"\n    | \"(\" ~ num_literal ~(\",\" ~ num_literal)* ~ \")\"\n}\n\nnum_literal = @{\n    \"-\"?\n    ~ (\"0\" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)\n    ~ (\".\" ~ ASCII_DIGIT*)?\n    ~ (^\"e\" ~ (\"+\" | \"-\")? ~ ASCII_DIGIT+)?\n}\n\nstring_literal = ${ \"\\\"\" ~ string ~ \"\\\"\" }\nstring = @{ char* }\nchar = {\n    !(\"\\\"\" | \"\\\\\") ~ ANY\n    | \"\\\\\" ~ (\"\\\"\" | \"\\\\\" | \"/\" | \"b\" | \"f\" | \"n\" | \"r\" | \"t\")\n    | \"\\\\\" ~ (\"u\" ~ ASCII_HEX_DIGIT{4})\n}\n\nWHITESPACE = _{ \" \" | \"\\n\" | \"\\r\" }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcch123%2Felastic-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcch123%2Felastic-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcch123%2Felastic-rs/lists"}