记录生活
标签 Tag : es

elasticsearch里的search_type

<Category: Diving Into ElasticSearch> 发表评论

elasticsearch里面的search_type共有如下几种:
The type of the search operation to perform. Can be
dfs_query_then_fetch,
dfs_query_and_fetch,
query_then_fetch,
query_and_fetch. 【removed,since:http://groups.google.com/group//browse_thread/thread/7aa5ea823afb499/d9e3cf3a1e1f6964】
Defaults to query_then_fetch.

form google group:“
You get proper sorted results when you use query_then_fetch (across all top
"size" results), if you use query_and_fetch, then each shard return the size
requested hits, and then they are sorted between them.

直接看代码里面吧,里面都有注释。

public enum SearchType {
    /**
     * Same as {@link #QUERY_THEN_FETCH}, except for an initial scatter phase which goes and computes the distributed
     * term frequencies for more accurate scoring.
     */
    DFS_QUERY_THEN_FETCH((byte) 0),
    /**
     * The query is executed against all shards, but only enough information is returned (not the document content).
     * The results are then sorted and ranked, and based on it, only the relevant shards are asked for the actual
     * document content. The return number of hits is exactly as specified in size, since they are the only ones that
     * are fetched. This is very handy when the index has a lot of shards (not replicas, shard id groups).
     */
    QUERY_THEN_FETCH((byte) 1),
    /**
     * Same as {@link #QUERY_AND_FETCH}, except for an initial scatter phase which goes and computes the distributed
     * term frequencies for more accurate scoring.
     */
    DFS_QUERY_AND_FETCH((byte) 2),
    /**
     * The most naive (and possibly fastest) implementation is to simply execute the query on all relevant shards
     * and return the results. Each shard returns size results. Since each shard already returns size hits, this
     * type actually returns size times number of shards results back to the caller.
     */
    QUERY_AND_FETCH((byte) 3),
    /**
     * Performs scanning of the results which executes the search without any sorting.
     * It will automatically start scrolling the result set.
     */
    SCAN((byte) 4),
    /**
     * Only counts the results, will still execute facets and the like.
     */
    COUNT((byte) 5);
 
    /**
     * The default search type ({@link #QUERY_THEN_FETCH}.
     */
    public static final SearchType DEFAULT = QUERY_THEN_FETCH;
 
    }

本文来自: elasticsearch里的search_type

ElasticSearch RESTful 接口调试记录&Tips

<Category: 搜索> 发表评论

RESTful接口调试日志记录。未整理,纯流水记录。
阅读这篇文章的其余部分 »

本文来自: ElasticSearch RESTful 接口调试记录&Tips

ElasticSearch复杂查询DSL使用

<Category: 搜索> 发表评论

测试ES版本0.10.0,ES的Query DSL很灵活,可以实现复杂的查询,这里提供个简单的例子。

curl -XGET 'http://localhost:9200/_all/default/_search?pretty=true' -d '
{
    "explain": true,
    "from": 1,
    "size": 12,
    "fields": [
        "HasExperience",
        "Name"
    ],
    "query": {
        "term": {
            "HasExperience": true,
            "__TENANTID": "100001"
        },
        "range": {
            "Age": {
                "from": 0,
                "to": 100,
                "includeLower": true,
                "includeUpper": true
            }
        }
    }
}
'

阅读这篇文章的其余部分 »

本文来自: ElasticSearch复杂查询DSL使用