DSL(Domain Specific language): How to get it

13. 搜索引擎-ES-DSL(Domain Specific Language) Domain-Specific Language(DSL,领域特定语言)是一种专为特定应用领域设计的计算机语言。语法和语义紧密贴合某一特定问题域,旨在提高该领域内开发或表达的简洁性、可读性和安全性。 阅读详情

同步自:http://www.blogjava.net/AndersLin/archive/2006/07/08/57222.html

在DSL:基于规则系统组织业务规则我提出DSL,不过在该文没有太多关于DSL的东东,显得有些牵强。

先要说明一下什么是DSL(Domain Specific language),援引《产生式编程》一文:
“DSL(领域特定语言)是一种特化的,面向问题的语言。”
《产生式编程》对DSL的做如下分类:
1. 固定和独立的DSL(fixed, sparate DSL),如SQL,用独立转换器实现的,导致技术孤岛
2. 嵌入式的DSL(Embedded DSL),如类和过程,还有嵌入式的DSL
3. 模块可组合的DSL(Modularly Composable DSL),包含两种DSL:封装的DSL(encapsulated DSL)和方面性(aspectual DSL)。这个两个关系就象OOP和AOP之间的关系。
 
好了,DSL是面向问题域的。换句话说,DSL是用来解决(特定)问题。
1. DSL更多的是表述特定问题域的,这是和常见编程语言的最大区别,编程语言不是面向特定的问题域的,而是一般问题域。
  1.1 DSL中关于问题域的名词是关键字,而编程语言不是。
对于保险行业来说: 代理人,保单都是DSL中的关键字,而在编程语言中不是,需要建立起该对象(OO语言中)。
同时注意:OO追求的是一个细粒度的设计,而在DSL中可以是相对的一个粗粒度的概念。DSL中对象体系的观念并不直接。
  1.2 DSL不处理编程语言中所涉及到的技术问题。
 
2. DSL是针对一个问题域的过程化表述。DSL基于特定问题域的关键字——名词,给出一个特定问题的流程。
按我在《小议领域模型Domain Model》一文中的观点,Domain Object都是DSL的关键字,而DSL表述的是Domain Service所包含的流程和规则。
 
举个例子:
如果某学生的这个学期期末考成绩90分以上超过5门,那么该学生就可以获得一个小红花。
 
用DSL来描述就可能是: 

foreach students
 
if  the total number of { the courses of {the student} { this  term} that {it ' s grade > 90} } >  5  then
   the student get a red flower
 end 
if
end foreach



 而用Java程序代码(假想代码) 

Iterator studentIterator  =  students.iterator();
while (studentIterator.hasNext()){
    Student student 
=  (Student)studentIterator.next();
    
//  从教务处获取学习成绩, 
    
//  SchoolService表示教务处,"200602"是学期代号。
    CourseGrade[] grades  =  SchoolService.getCourseGrade(student,  " 200602 " );
    
int  i  =   0 ;
    Iterator gradeIterator 
=  grades.iterator();
    
while (gradeIterator.hasNext()){
        CourseGrade courseGrade 
=  (CourseGrade)gradeIterator.next();
        
if (courseGrade.getGrade()  >   90 ){
            i
++ ;
        }
    }
    
if (i > 5 ){
        
//  学校为该生记一个小红花的奖章。
        SchoolService.addMedal(student,  " 200602 " ,  new  RedFlower());
    }
}


从上面可以看出,用DSL描述很简洁。(自己立了靶子,然后开打) 
这里我要说明的是:student和course都DSL的关键字,而在java代码中不是,是开发中建立的对象体系。
DSL中没有涉及到编程语言的技术处理问题:
1. java代码中的转型:(Student)studentIterator.next();
2. 临时变量:int i = 0;
3. 新建对象: new RedFlower()
同时:DSL中我们隐藏了一个SchoolService对象,在技术上,SchoolService教务处记录学生的成绩和奖惩,student本身不带有这些信息。
(当然关于这个例子的设计,或许有人认为student本身可以拥有这些记录,不过由于这个course还关联教师对象等,所以单独管理。BTW:例子而已表太认真嘛!)
 
通常来说Use Case描述更多是是问题域的描述。
 
这里面DSL的关键字:所谓的问题域名词(也就是我们所说的Domain Model)的设计和建立就是DSL的实现的关键,现有的手段无非就两种:
1. 工具本身内置支持Domain Object的设计和实现。这个是正统的路子。
2. 利用外置工具实现,这个有点剑走偏锋的意思。
 
常见的有以下几条路子:
一.映射法。
如Drools3推出的DSL实现方式。来看看springside的例子 

package  org.springside.dsl 
  
import  org.springside.bookstore.domain.Order 
import  java.lang.Double 
import  java.math.BigDecimal 
  
expander orderPricing.dsl 
  
rule 
"  order 0.9 discount "  
    when 
       order price larger than 
100  
    then 
       
do   0.9  discount 
       #加入 
>  就可以在drl / dsl 中直接写入drl 语法 
       
> System.out.println( " original price: " + order.getOriginalPrice() + "  discount price: " + order.getTotalPrice()); 
end 

 
注意这个expander orderPricing.dsl将导入DSL映射: 

[when]order price larger than {topPrice} = order : Order( totalPrice  >=  {topPrice} ) 
[then]
do  {discountRate} discount = order.setTotalPrice( new  Double( new  BigDecimal(order.getTotalPrice().doubleValue()  *  {discountRate}).setScale( 2 , BigDecimal.ROUND_HALF_UP).doubleValue())); 

 
Oracle的Rule编辑器和JRule也属于这一类。
 
二.解析法
1. 脚本解析:
用脚本做有天然的好处,动态类型,语法的易用性等等。
出名的有Ruby:http://www.artima.com/rubycs/articles/ruby_as_dsl.html
2. 程序解析:
ajoo同学的jaskell的dsl方案:
http://forum.javaeye.com/bloglist.php?userid=6423
http://forum.javaeye.com/viewtopic.php?t=17579&start=120
 
或许这样分不太好,不过从本质上看,两者都通过提供相对灵活的语法解析来使代码简洁更贴近问题域描述。 
  
映射法和解析法两者都不提供Domain Model的设计支持,两者只是在代码生成手段上有所不同。 
在《DSL:基于规则系统组织业务规则》一文中所提出的组织业务规则的DSL就是指这两种。 

三.元数据生成法。
这类属于正统手法,当然也是复杂性最大的。
1. JetBrains的MPS(Meta Programming System)。
MPS的定义流程很严格
1. 首先定义基本的关键字--Struture,然后要定义其对应的editor,相当于MS VS的Designer,
2. 有了这个后就可以作为high level的模型,用来设计Model,就可以设计描述领域问题。
3. 定义low level的代码产生器,定义转换映射关系。
 
可以参照Drools的设计实现来理解MPS的工作原理:
1. 定义DSL文件的左表达式(MPS在这里还需要设计好editor,drools合二为一了)。
2. 基于这个表达式定义领域问题。
3. 定义DSL的右表达式,以便代码生成。
 
MPS采用XML结构化的节点扩展能力来实现Type的定义,可以看到其GUI工具生成的mps文件是晦涩难懂的。
 
2. Microsoft的意图编程(Intentional Programming),只在《产生式编程》中闻其大名,未见真身。
不过微软推出了VS.Net的DSL Tools,不知道是不是意图编程的成果。
http://msdn.microsoft.com/vstudio/DSLTools/
http://www.microsoft.com/downloads/details.aspx?familyid=57a14cc6-c084-48dd-b401-1845013bf834&displaylang=en
 
MS DSL的model定义也是采用XML,没有designer的帮助,也是晦涩难懂的。
不过,其模版生成采用类似ASP.NET一样的语法结构,来定义模版(Text Template)。而不是想MPS那样,在MPS和IntelliJ两个工具切换来切换去的,同时也相对容易上手。
相比而言,MPS显的庞大,VS DSL则简单明了。
这正好反应了JAVA世界和MS世界的不同,MS一向是怎么样简单就怎么来,而JAVA更多像学院派风格。  
 
准备另外写Blog详细介绍MPS和MS的DSL Tools,这是后话。
 
另:TW的taowen同学在BJUG的google groups上有过讨论,还发了一文《DSL简单观察报告》。有很好讨论,不过不好贴出来。
 

手把手教你用STM32CubeMX和HAL库驱动DW3000:从SPI配置到第一个测距Demo 本文详细介绍了如何使用STM32CubeMX和HAL库驱动DW3000 UWB定位通信模块,从SPI配置到实现厘米级测距Demo的全过程。涵盖硬件连接、SPI通信调试、驱动移植及双向测距(TWR)算法实现,帮助开发者快速掌握UWB高精度定位技术,适用于仓储物流、智能家居等场景。 阅读详情

相关推荐

基于PLC的矿用排水控制系统设计【附代码】

(3)矿用排水控制系统的软件设计 研究设计了矿用排水控制系统的软件,包括PLC程序的编写和上位机监控画面的设计。(2)矿用排水控制系统的硬件设计 研究对矿用排水控制系统的硬件进行了选型和设计,包括矿用多级耐磨离心泵、三相异步防爆电机等执行设备的选型,以及控制系统所需用到的各类型传感器、PLC的I/O点分配及选型。(1)矿用排水控制系统的现状分析 研究首先对矿井排水系统的现状进行了分析,指出了现有系统存在的问题,如自动化程度低、劳动强度大、设备维护困难等。✅ 具体问题可以私信或查看文章底部二维码。

lagougongzuoshi的博客 1174

【日常记录:商品检索服务】java实现封装DSL语句

以下是继续从BoolQueryBuilder调用must方法,再从must方法里边调用QueryBuilders.matchQuery这样就完成了第一个。是上篇文章根据业务分析锁封装的前端的查询条件,最终将es的检索和聚合条件封装完了之后再返回。然后再从bool里继续嵌套,只要用到es中的检索方法就使用QueryBuilders来调用。前一篇已经根据业务分析了es的查询结构,这篇就开始用java操作es进行封装。总体思路还是对照着所构建好的DSL查询语句,一一对应进行封装。最终将构建好的条件全部拿过来。..

qq_17593727的博客 1198

Quanto option期权公式推导(更新中)

Quanto期权不同于以标的股票或资产的计价货币支付最终收益的普通欧式期权,它以另一种货币以预先确定的汇率支付最后的收益。以股票B的计价货币来计价的quanto看涨期权的收益为F0×max⁡(Sa(T)−K,0)×Sb(T)F_0 \times \max(S_a(T)-K, 0) \times S_b(T)F0​×max(Sa​(T)−K,0)×Sb​(T) 其中SaS_aSa​以货币A计价,SbS_bSb​以货币B计价,F0F_0F0​是预先固定的汇率. 假设上述股票均遵循几何布朗运动,可以得到以下恒等式

qq_41782124的博客 3683

DSL 领域特定语言

一、DSL介绍 DSL(Domain Specific Language)是针对某一领域,具有受限表达性的一种计算机程序设计语言。 常用于聚焦指定的领域或问题,这就要求 DSL 具备强大的表现力,同时在使用起来要简单。说到DSL,大家也会自然的想到通用语言(如Java、C等)。 为什么没有一种语言同时 兼具『简洁』和『业务表达』能力呢? 从信息论本质上来讨论这个问题,每个语言的程序都可以抽象为一个字符串,每个字符串由有限数量的合法字符组成,它在运行时会实现某个功能,因而可以看作是一种需求的信源编码。每

Sunny的专栏 3万+

【Xilinx】如何在petalinux下编译vcu-gst-app以及独立编译vcu-gst-app

Xilinx从2018.1开始,提供了一套基于zcu106的vcu参考设计。里面提供了一套基于GStreamer的程序,即vcu-gst-app。如何脱离petalinux直接编译呢,这里以为例,其他版本也是类似的操作。

王师傅 3040

STM32 SAI接口实战:用CubeMX快速配置多通道音频采集(附DMA优化技巧)

本文详细介绍了如何使用STM32的SAI接口通过CubeMX快速配置多通道音频采集系统,并提供了DMA双缓冲优化技巧。内容涵盖TDM模式配置、时钟同步、DMA优化及常见问题排查,帮助开发者高效实现高速数据采集应用。

weixin_42549037的博客 225

MDSF:DSL(Domain Specific Language)介绍

前面介绍过模型驱动开发(MDD)、软件工厂(Software factory)、特定领域建模 DSM(Domain Specific)等都是高抽象的开发方法,这些方法使用的语言都是特定领域语言(DSL)。相比于通用目的语言(C#/C++/JAVA/Delphi等)而言,DSL是一种为了特定任务而设计的开发语言,例如SQL是一种专门处理数据库的语言,本篇将介绍一下DSL。 一种语言   我们熟知...

weixin_34289744的博客 467

基于Lstm+transformer的刀具磨损预测实战

基于Lstm+transformer的刀具磨损预测实战

2906

走近“领域特定语言”(Domain-Specific Languages)

领域特定语言(Domain-Specific Languages,简称DSL),是一个很有用的术语和概念,但其边界很模糊。一些东西很明显是DSL,但另一些可能会引发争议。本文接下来就走近“领域特定语言”,了解它的概念、为何要采用DSL,以及使用时应该注意的问题。 1.定义DSL 领域特定语言(名词),针对某一特定领域,具有受限表达性的一种计算机程序设计语言。这一定义包含4个关键元素: 计算机...

华章IT官方博客 1676

Linux系统故障排查思路实践教程(上)

本文主要介绍了Linux系统日志分析与常见故障排查的实用方法。首先从系统日志的分类及其涉及的日志文件进行说明;其次详细讲解了忘记用户密码的解决方案;接着对系统无法启动问题,提供了异常断电后修复文件系统、/etc/fstab文件丢失恢复等常见故障的处理方案。最后介绍了文件系统只读错误的排查思路和修复方法,包括磁盘空间检查、文件系统修复等实用技巧。全文提供了大量具体命令和操作流程,为Linux系统维护人员提供了实用的故障处理指南。

提供C#相关开发 、云计算、运维测试、网络安全相关技术分享与服务,有意向可联系。 329

AI技术在电商中的实际应用

人工智能、电商、推荐系统、个性化、机器学习、深度学习 1. 背景介绍 电子商务行业近年来发展迅速,用户数量不断增长,商品种类日益丰富。然而,随着市场竞争的加剧,电商平台面临着如何提升用户体验、提高转化率、挖掘潜在商机等一系列挑战。人工智能(AI)技术作为一种新兴技术,凭借其强大的数

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 1740

ElasticSearch-Query DSL(Domain Specific Language)

elasticsearch

抽象的螺旋 1362

【Bug已解决】codex: debug 模式无输出 — CodeX CLI 调试模式不工作解决方案

CodeX CLI 开启 debug 模式后无输出/日志不打印的解决方案,含 debug 开关、日志级别、stderr 重定向与 IDE 日志面板。

一键难忘的博客 4165

DSL搜索 - 入门语法

目录请求参数的查询(QueryString)DSL基本语法搜索不合法问题定位 请求参数的查询(QueryString) 查询[字段]包含[内容]的文档 GET /shop/_doc/_search?q=desc:慕课网 GET /shop/_doc/_search?q=nickname:慕&q=age:25 text与keyword搜索对比测试(keyword不会被倒排索...

柏~的博客 447

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

Elasticsearch DSL(Domain Specific Language)基本语法

Elasticsearch(ES)的查询语法(DSL)是其核心功能,基于JSON格式实现灵活的数据检索与分析。

qq_44174090的博客 335

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Query DSL(Domain Specific Language)

概念:相关度评分用于对搜索结果排序,评分越高则认为其结果和搜索的预期值相关度越高,即越符合搜索预期值。:可以组合多个查询条件,bool查询也是采用more_matches_is_better的机制,因此满足must和should子句的文档将会合并起来计算分值。使用query关键字进行检索,倾向于相关度搜索,故需要计算评分。因为filter不计算评分,所以性能更高,可以先根据filter筛出部分数据,再进行其他条件的筛选。排序:相关度评分为搜索结果的排序依据,默认情况下评分越高,则结果越靠前。

weixin_41063119的博客 155

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

常用DSL语句

常用DSL语句 查看所有索引 GET /_cat/indices?v 删除某个索引 DELETE /skuinfo 新增索引 PUT /user 创建映射 PUT /user/userinfo/_mapping { "properties": { "name": { "type": "text", "analy...

cs950809的博客 3048

ES DSL、特性、索引、基概、进阶

文章目录elasticsearch1 特点1.1 天然分片,天然集群1.2 天然索引1.3 lucene倒排索引结构2 基概3 状态介绍3.1 状态13.2 状态24 es中的DSL4.1 数据结构4.2 增加操作4.3 更新操作4.4 删除索引4.5 查询操作4.6 分页查询4.7 聚合 elasticsearch 1 特点 1.1 天然分片,天然集群 实则es是把这个数据分为多个碎片分布式的放在各个节点上,随着数据的增加会将其增加节点数,将多个分片放在多个节点上,以此达

友培的博客 2140

ElasticSearch DSL 领域专用语言

博文目录 文章目录ElasticSearch DSL(Domain Specific Language) 领域专用语言Query DSLFilter DSL区别查询无查询条件有查询条件叶子查询(单条件)模糊匹配matchmatch 的底层转换multi_matchmatch_phrasematch phrase 原理 - term positionmatch phrase搜索参数 - slopquery_string前缀搜索 prefix通配符搜索 wildcard正则搜索搜索推荐模糊搜索技术 fuzzy总

mrathena 487

DSL语法实例

API的基本用法: GET /user/_doc/_search { "query": { "match_all": {} }, "from": 0, "size": 100 } 查找 GET /user/_doc/_search { "query":{ "bool":{ "must":{ "term":{"tag":"好"} } } } } 更新或添加文档 PUT /user/_doc/张三 { "usern...

junqing124的专栏 812

Elastic Stack核心技术实战02--Elasticsearch中的Domain Specific Language详解

上一篇博客中给大家介绍了Elasticsearch单机版的环境搭建以及简单的增删改查,今天我们就来学习一下Elasticsearch的Domain Specific Language,也就是我们常说的DSL查询。在es中以JSON的格式出现。 在此之前先给大家介绍一下分词器,首先 ...

代码洁癖症患者 618

ElasticSearch中DSL高级检索(Query)

ES官方提供了两中检索方式:一种是通过 URL 参数进行搜索,另一种是通过 DSL(Domain Specified Language) 进行搜索。官方更推荐使用第二种方式第二种方式是基于传递JSON作为请求体(request body)格式与ES进行交互,这种方式更强大,更简洁。

程序员小王的博客 2507

用写sql的思路写 Elasticsearch 的DSL

目录Elasticsearch的DSL基础操作基础查询筛选查询多条件教材筛选聚合查询排序对结果分页查询kibana可视化图表配置 先挖坑,慢慢填 Elasticsearch的DSL 基础操作 GET POST DELETE PUT HEAD 基础查询 筛选查询 多条件教材筛选 聚合查询 排序 对结果分页查询 kibana可视化图表配置 (这个可以单开一个的吧) ...

Neon Light 的博客 266

dsl mysql_ES中查询语句DSL(domain specific language)

#查看所有索引GET/_cat/indices?v#删除某个索引DELETE/skuinfo#新增索引PUT/user#创建映射PUT/user/userinfo/_mapping{"properties": {"name":{"type": "text","analyzer": "ik_smart","search_analyzer": "ik_smart","store": false},"c...

weixin_39653481的博客 217

Java-ES-DSL操作-查询

查询所有以cust开头的索引 GET /cust*/_search?pretty 返回bank索引中的所有的文档: GET /bank/_search?q=*&pretty 等同于: POST /bank/_search?pretty { "query": {"match_all": {}} } 指定返回第11到第20个文档,并指定返回字段: POST /bank/_sear...

fayxjc的博客 2537

Elasticsearch DSL指令请求前缀解析:快速参考指南【记录】

DSL全称为"Domain Specific Language",英译中的结果就是,领域特定语言。指的是专注于某个应用程序领域的计算机语言,又译作领域专用语言。不同于其他计算机语言,顾名思义,这种语言只用在某些特定的领域。

单枪匹码 2639
上一篇: DSL(Domain Specific language): How to get it
下一篇: 项目闹鬼之hibernate2.1.6
林仪明
博客等级 码龄25年 313粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值