elastica

ElasticSearch group by documents field and count occurences

可紊 提交于 2020-01-25 06:53:27
问题 My ElasticSearch 6.5.2 index look likes: { "_index" : "searches", "_type" : "searches", "_id" : "cCYuHW4BvwH6Y3jL87ul", "_score" : 1.0, "_source" : { "querySearched" : "telecom", } }, { "_index" : "searches", "_type" : "searches", "_id" : "cSYuHW4BvwH6Y3jL_Lvt", "_score" : 1.0, "_source" : { "querySearched" : "telecom", } }, { "_index" : "searches", "_type" : "searches", "_id" : "eCb6O24BvwH6Y3jLP7tM", "_score" : 1.0, "_source" : { "querySearched" : "industry", } And I would like a query that

Check Elasticsearch document similarity before indexing

痞子三分冷 提交于 2020-01-25 03:04:07
问题 Ok after having pulling my hair off all day long trying to figure that one out I decided to get some input from the community. Should be mentioned that I'm fairly new to Elasticsearch. The idea is that I have an ES index containing some documents and I need to index new documents only if no existing documents with similar field content (but not necessarily equals) are already indexed. I can perform a match query on multiple field and get a global score for the query but since that score is

Boosting an elasticsearch result based on a boolean field value

允我心安 提交于 2019-12-24 10:55:47
问题 I'm getting a lot of "static" when searching for the correct way to boost a result when a "Boolean" field type is TRUE, most results are talking about boolean searches. N.B. We're using the php elastica library but if you can only provide json that's fine, I can manage from that. I have an index with 5 fields where we have some built in boosting going on as you can see here: array( 'article_id' => array('type' => 'string', 'include_in_all' => FALSE), 'subject' => array('type' => 'string',

Elasticsearch match substring in php

旧巷老猫 提交于 2019-12-22 04:07:40
问题 Below given is my code to generate index using elasticsearch.Index is getting generated successfully.Basically I am using it to generate autosuggest depending upon movie name,actor name and gener. Now my requirement is, I need to match substring with particular field.This is working fine if I use $params['body']['query']['wildcard']['field'] = '*sub_word*'; .(i.e. search for 'to' gives 'tom kruz' but search for 'tom kr' returns no result). This matches only particular word in string.I want to

Elasticsearch filter via number of mentions

淺唱寂寞╮ 提交于 2019-12-22 01:31:51
问题 I am trying to write a query which will return me articles about certain keywords but I want the articles to only show if the the given keyword is mentions 5 times in the articles I am using following query But no result { "query":{ "multi_match":{ "query":"Apple", "operator":"AND", "fields":[ "Text" ] } ,"min_term_freq" : 5 }, "sort":{ "Date":{ "order":"desc" } } } 回答1: I dont believe there is any min_term_freq option as you have listed. But then you can use scripting in filter to achieve

Elasticsearch relationship mappings (one to one and one to many)

天大地大妈咪最大 提交于 2019-12-17 15:35:58
问题 In my elastic search server I have one index http://localhost:9200/blog . The (blog) index contains multiple types. e.g.: http://localhost:9200/blog/posts , http://localhost:9200/blog/tags . In the tags type I have created more than 1000 tags and 10 posts created in posts type. e.g.: posts { "_index":"blog", "_type":"posts", "_id":"1", "_version":3, "found":true, "_source" : { "catalogId" : "1", "name" : "cricket", "url" : "http://www.wikipedia/cricket" } } e.g.: tags { "_index":"blog", "

Elasticsearch connect range and term to same array item

假如想象 提交于 2019-12-13 22:18:43
问题 I have a user document with a field called experiences which is an array of objects, like: { "experiences": [ { "end_date": "2017-03-02", "is_valid": false }, { "end_date": "2015-03-02", "is_valid": true } ] } With this document I have to search users where end date is in last year and is_valid is true. At this time I have a query -> bool and I add two must there, one range for the end_date and one term for the is_valid . { "query": { "bool": { "must": { "term": { "experiences.is_valid": true

How do I group documents in elasticsearch by a single field?

女生的网名这么多〃 提交于 2019-12-11 13:15:10
问题 If I have a bunch of documents in elaticsearch that I want to be returned grouped by the one field of the document, how do I do it? Also I need it to consistently return a fixed number of results (using set maxresults) For example if I have a bunch of documents each document representing a person and fields of the document containing attributes of the person. Let's say each person has a city field in the document. I would like to query Elasticsearch in a way that will return 50 results that

Elasticsearch OR query

狂风中的少年 提交于 2019-12-11 04:09:04
问题 Can anyone tell me how do I write the below Mysql query in elastisearch Select * from `table` WHERE `Name`='A' OR `Name`='B' order by `rank` DESC I have tried multiple solutions the internet like { "sort":{"rank":{"order":"desc"}}, "query": { "query_string" : { "fields" : ["Name"], "query" : "A OR B" } } and also tried the below code { "sort":{"rank":{"order":"desc"}}, "query" : { "bool": { "should": [ { "match_phrase" : { "Name" : "A" } }, { "match_phrase": { "Name": "B" } } ] } } } 回答1: You

Installation and using elasticsearch php client on Windows Xampp

时间秒杀一切 提交于 2019-12-10 10:12:34
问题 I'm downloaded the elasticsearch-5.1.1.zip from the https://www.elastic.co/downloads/elasticsearch Then download the Elastica A PHP client for elasticsearch via composer with this command composer require ruflin/elastica:dev-master Now i want to open and make a test. When i run this command bin\elasticsearch.bat i get this error: The syntax of the command is incorrect. On the other side if i try to use Elastica A PHP client i get some errors like this: Fatal error: Uncaught Elastica\Exception