Skip to content

elastic如何应用

chenrenfei edited this page Feb 20, 2018 · 1 revision

两种模式

	<eql id="sys_elastic_test" fields="chineseName,price,trademarkId">
		<value>
		<![CDATA[
			select * from goods_index
			where 1=1
			#[and chineseName =matchPhrase(:keyword)]
			#[and manufacturerName =matchPhrase(:keyword2)]
			#[and trademarkName =matchPhrase(:keyword3)]
			#[and goodsCateId in (:goodsCateIds)]
			#[and transactionType =:transactionType]
			#[and trademarkId =:trademarkId]
			#[and uom =:uom]
			#[and :endPrice >=price]
			#[and price >=:startPrice]
			#[@if(:priceSort==1 && :transactionSort==1) order by price desc,days desc,upTime desc]
			#[@if(:priceSort==0 && :transactionSort==0) order by price asc,days asc,upTime desc]
			#[@if(:priceSort==1 && :transactionSort==0) order by price asc,days asc,upTime desc]
			#[@if(:priceSort==0 && :transactionSort==1) order by price asc,days asc,upTime desc]
		]]>
		</value>
	</eql>
调用模式: 继承BaseDaoSupport
@Repository("staffInfoDao")
public class StaffInfoDao extends BaseDaoSupport {
	public PaginationModel findESPageBySql(PaginationModel pageModel, GoodsParam goodsParam) throws Exception {
		return elastic().sql("query_goods").entity(goodsParam).resultType(Goods.class).findPage(pageModel);
	}
}
Clone this wiki locally