跳至主要内容

博文

目前显示的是 十一月, 2017的博文

SLF4J Introduction(2): Output

SLF4J Introduction(2): Output In this blog, we focus on how SLF4J and related logging system handle the output of logging. Layout Layout, which is maybe called pattern, is responsible to transform an log event into string with some format. The format of the log event is somewhat like printf method. There are many conversion characters to represent things like class name, date, thread, file name, stack trace, message, caller data etc. Log4j In log4j, the default conversion pattern is %r [%t] %p %c %x - %m%n % : the prefix of conversion character. If we want to print a single % sign, we can use %% r : the number of milliseconds elapsed from the construction of the layout until the creation of the logging event. t : name of thread p : logging priority c : the category of the logging event x : NDC (nested diagnostic context) m : the application supplied message associated with the logging event n : the platform dependent line separator character or c

Elasticsearch Adventure(3): Dev & Ops

Elasticsearch Adventure(3): Dev & Ops The earch engine project now is in test environment. Tony now do some operations of search system to maintain the Elasticsearch cluster. This process is a new adventure in Elasticsearch. har oct s nteerais a e inencers hicss i ane er n lssearch uste to toy er sarinte n. atineieer sad no aee de t tisarhe t ctrhameoce s, used tau reeae e r srd aalot o i shards led o or #### Cluster Health "Tony, tony. Come here. Your Elasticsearch cluster in state of red now." Operation engineer said loudly. So, Tony log in server and check the Elasticsearch cluster state: $curl '192.168.1.100:9200/_cluster/health?pretty' { eeaner rustrealthre "cluster_name" : "searcher-dev" , "status" : "red" , ... "unassigned_shards" : 3 , ... "number_of_pending_tasks" : xxx , } “Statuys is red because some primary shards are not allocated 1 .

Elasticsearch Learning (4): Mappings

Elasticsearch Learning (4): Mappings “Today, we are going to dive into one of the most important settings when we use Elasticsearch, mappings, which is related to how is ES interpreting our document JSON, how is ES analyzing our field and indexing document, how is ES searching for our request.”, Tony said in the technology sharing time. Mapping and Analysis “As we all known, there exists different data types in common databases, and ES also has some common data types.”, Tony. Text: string for full text search Keyword: string for exact match Whole number: byte, short, integer, long Floating-point: float, double Boolean: boolean Date: date " Text type and Keyword type seems different, can you explain what’s the difference?", someone asked. Tony, “Good question. But before we explain their differences, we need to understand there exists two large categories of data types: exact values and full text” Exact Values vs Full Text "Data in Ela

Elasticsearch Adventure(2): Better Practice?

With the development and testing of search engine, Tony met more problems. Now, he learned much basic things about Elasticsearch, and he is seeking better practice for problems. Query Condition Combination Tony, “Mentor, I am using rest API of Elasticsearch to assist the access of Elasticsearch for the time being. Now we have a requirement of very flexible searching: user can choose and combine different fields using checkbox to search. I am wondering how to implement it gracefully. For now, I can only think about using different pre-write query string of ES, but it seems cumbersome and I think I may need some string builder to compose a customized query.” Tim, “Em, maybe QueryBuidlers of Elasticsearch Java API is what you want. Let’s say we want a bool query 1 , and the condition for query may exists or not. So we can do like following:” BoolQueryBuilder bool = boolQuery ( ) . should ( matchQuery ( "must_have1name" , info . getQuery ( ) ) ) . should ( neste

Elasticsearch Adventure(1): Trial and Error

Elasticsearch Adventure(1): Trial and Error Tony is an energetic graduate from University who is admitted by a software company. He is interested in many new technology and recently, he is responsible for developing a simple search engine for test. He skim the basic tutorials and books online ( ES Introduction , Elasticsearch Concepts Confusion , etc ) and start developing his search engine. With the development of searching system, hwe came across more problems of Elasticsearch usage. Fortunately, he has a mentor, Tim, who has rich experience of ES. Query String Tony: “Mentor, our search engine has the requirement of special search techniques, like xx AND yy for intersection of result, aa OR bb for union. Does ES support the interception of similar content?” Tim: “Yes, ES support this features. It has query called query string query . Let’s see an example” GET / _search { "query" : { "query_string" : { &quo