Search in sources :

Example 21 with ProfileResult

use of org.elasticsearch.search.profile.ProfileResult in project elasticsearch by elastic.

the class QueryProfilerTests method testNoScoring.

public void testNoScoring() throws IOException {
    QueryProfiler profiler = new QueryProfiler();
    searcher.setProfiler(profiler);
    Query query = new TermQuery(new Term("foo", "bar"));
    // scores are not needed
    searcher.search(query, 1, Sort.INDEXORDER);
    List<ProfileResult> results = profiler.getTree();
    assertEquals(1, results.size());
    Map<String, Long> breakdown = results.get(0).getTimeBreakdown();
    assertThat(breakdown.get(QueryTimingType.CREATE_WEIGHT.toString()).longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.BUILD_SCORER.toString()).longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.NEXT_DOC.toString()).longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.ADVANCE.toString()).longValue(), equalTo(0L));
    assertThat(breakdown.get(QueryTimingType.SCORE.toString()).longValue(), equalTo(0L));
    assertThat(breakdown.get(QueryTimingType.MATCH.toString()).longValue(), equalTo(0L));
    assertThat(breakdown.get(QueryTimingType.CREATE_WEIGHT.toString() + "_count").longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.BUILD_SCORER.toString() + "_count").longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.NEXT_DOC.toString() + "_count").longValue(), greaterThan(0L));
    assertThat(breakdown.get(QueryTimingType.ADVANCE.toString() + "_count").longValue(), equalTo(0L));
    assertThat(breakdown.get(QueryTimingType.SCORE.toString() + "_count").longValue(), equalTo(0L));
    assertThat(breakdown.get(QueryTimingType.MATCH.toString() + "_count").longValue(), equalTo(0L));
    long rewriteTime = profiler.getRewriteTime();
    assertThat(rewriteTime, greaterThan(0L));
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Query(org.apache.lucene.search.Query) RandomApproximationQuery(org.apache.lucene.search.RandomApproximationQuery) TermQuery(org.apache.lucene.search.TermQuery) ProfileResult(org.elasticsearch.search.profile.ProfileResult) Term(org.apache.lucene.index.Term)

Example 22 with ProfileResult

use of org.elasticsearch.search.profile.ProfileResult in project elasticsearch by elastic.

the class QueryProfilerTests method testUseIndexStats.

public void testUseIndexStats() throws IOException {
    QueryProfiler profiler = new QueryProfiler();
    searcher.setProfiler(profiler);
    Query query = new TermQuery(new Term("foo", "bar"));
    // will use index stats
    searcher.count(query);
    List<ProfileResult> results = profiler.getTree();
    assertEquals(0, results.size());
    long rewriteTime = profiler.getRewriteTime();
    assertThat(rewriteTime, greaterThan(0L));
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Query(org.apache.lucene.search.Query) RandomApproximationQuery(org.apache.lucene.search.RandomApproximationQuery) TermQuery(org.apache.lucene.search.TermQuery) ProfileResult(org.elasticsearch.search.profile.ProfileResult) Term(org.apache.lucene.index.Term)

Aggregations

ProfileResult (org.elasticsearch.search.profile.ProfileResult)22 SearchResponse (org.elasticsearch.action.search.SearchResponse)14 ProfileShardResult (org.elasticsearch.search.profile.ProfileShardResult)14 Map (java.util.Map)9 IndexRequestBuilder (org.elasticsearch.action.index.IndexRequestBuilder)9 MultiSearchResponse (org.elasticsearch.action.search.MultiSearchResponse)9 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)9 RandomQueryGenerator.randomQueryBuilder (org.elasticsearch.search.profile.query.RandomQueryGenerator.randomQueryBuilder)9 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)9 AggregationProfileShardResult (org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult)5 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)5 Term (org.apache.lucene.index.Term)4 Query (org.apache.lucene.search.Query)4 RandomApproximationQuery (org.apache.lucene.search.RandomApproximationQuery)4 TermQuery (org.apache.lucene.search.TermQuery)4 GlobalOrdinalsStringTermsAggregator (org.elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 ShardSearchFailure (org.elasticsearch.action.search.ShardSearchFailure)1