compose文件:
version: '2' services: consul-server: image: gliderlabs/consul-server:0.6 command: -bootstrap -advertise 192.168.10.138 hostname: consul-server ports: - "8400:8400" - "8500:8500" - "8600:53/udp" registrator: image: gliderlabs/registrator:latest command: consul://consul-server:8500 hostname: registrator depends_on: - consul-server volumes: - /var/run/docker.sock:/tmp/docker.sock app: image: tutum/hello-world:latest environment: # Environment variables used by registrator to register services in consul SERVICE_NAME: app SERVICE_TAGS: sample ports: - "8081:80" depends_on: - consul-template-nginx # Nginx Load Balancer consul-template-nginx: image: 1science/nginx:1.9.6-consul ports: - 80:80 volumes: - ./etc/consul-template:/etc/consul-tem
下面是全文检索引擎的初步应用,但是很遗憾,原生的lucene不支持中文分词,所以需要插件支持,在后面会继续讲到。
代码摘自:http://iluoxuan.iteye.com/blog/1708695
POM.xml文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.firewarm</groupId> <artifactId>testLucene</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</
注意,IK Analyzer需要使用其下载列表中的 IK Analyzer 2012FF_hf1.zip,否则在和Lucene 4.10配合使用时会报错。
import java.io.IOException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.queryparser.classic.ParseException; import
import java.io.IOException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.queryparser.classic.MultiFieldQueryParser; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.Version; import o
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn