KmalSQ is a Generic DSL that allows the generation of queries to multiple search and database engines (See more about the KmalSQ kernel). KmalSQ is part of a research in the field of domain-specific language design (DSL) and its application in the field of information search in search engines and databases. We are open to collaborations and suggestions.
-[x] Elasticsearch
KmalSQ allows the generation of queries for ElasticSearch, below are examples of how KmalSQ can be used to generate queries for ElasticSearch. Currently support for an executor and a query builder is provided to each integrated engine.
package mlix.global;
import mlix.global.build.ElasticSearchKmalBuildQuery;
import org.elasticsearch.index.query.QueryBuilder;
public class App {
public static void main( String[] args ) {
ElasticSearchKmalBuildQuery elasticSearchKmalBuildQuery = new ElasticSearchKmalBuildQuery();
String dslPrompt = "NOT [asin.keyword] == '1234567890';";
QueryBuilder queryBuilder = elasticSearchKmalBuildQuery.query(dslPrompt);
System.out.println(queryBuilder.toString());
}
}
KmalSQ prompt: [asin.keyword] == '0609804340';
->
{
"bool" : {
"must" : [
{
"match" : {
"asin.keyword" : {
"query" : "0609804340",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
KmalSQ prompt: ([reviews.entries.date] RANGOUT FROM 04/04/2004 TO 05/08/2005
AND [title.keyword] ENDS_WITH 'say') OR [title.keyword] CONTAINS 'something';
->
{
"bool" : {
"should" : [
{
"bool" : {
"must" : [
{
"bool" : {
"must_not" : [
{
"bool" : {
"must" : [
{
"range" : {
"reviews.entries.date" : {
"from" : 1081051200000,
"to" : 1123300799000,
"include_lower" : true,
"include_upper" : true,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must" : [
{
"wildcard" : {
"title.keyword" : {
"wildcard" : "*say",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must" : [
{
"wildcard" : {
"title.keyword" : {
"wildcard" : "*something*",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
KmalSQ prompt: NOT ([asin.keyword] == '0786926503' AND NOT ([title.keyword] STARTS_WITH 'The' OR [title.keyword] STARTS_WITH 'B'));
->
{
"bool" : {
"must_not" : [
{
"bool" : {
"must" : [
{
"bool" : {
"must" : [
{
"match" : {
"asin.keyword" : {
"query" : "0786926503",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must_not" : [
{
"bool" : {
"should" : [
{
"bool" : {
"must" : [
{
"wildcard" : {
"title.keyword" : {
"wildcard" : "The*",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
{
"bool" : {
"must" : [
{
"wildcard" : {
"title.keyword" : {
"wildcard" : "B*",
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}