본문 바로가기
웹/elasticsearch

test query

by java개발자 2019. 4. 26.

GET /bookdb_index/book/_search
    {
    "seq_no_primary_term": true,
    "track_total_hits": true,
    "_source": ["title"],
    "query" : {
        "match_phrase": { "title" : "guide" }
    }      
    }


    POST /twitter/_mtermvectors
{
   "docs": [
      {
         "_id": "2",
         "fields": [
            "message"
         ],
         "term_statistics": true
      },
      {
         "_id": "1"
      }
   ]
}

POST /_mtermvectors
{
   "docs": [
      {
         "_index": "twitter",
         "_id": "2",
         "term_statistics": true
      },
      {
         "_index": "twitter",
         "_id": "1",
         "fields": [
            "message"
         ]
      }
   ]
}

DELETE my_index

PUT my_index
{
  "mappings": {
    "properties": {
      "text": {
        "type":        "text",
        "term_vector": "with_positions_offsets"
      }
    }
  }
}

PUT my_index/_doc/1
{
  "text": "Quick brown fox"
}

GET my_index/_doc/1

GET my_index/_search
{
  "_source": "term_vector", 
  "query": {
    "match": {
      "text": "brown fox"
    }
  },
  "highlight": {
    "fields": {
      "text": {} 
    }
  }
}

GET /bookdb_index/book/_search
{
    "_source": ["title"],
    "query": {
        "match_phrase": { "title" : "solr" }
    },
 "highlight": {
        "type" : "unified",
        "number_of_fragments" : 3,
        "fields": {
            "title": {}
        }
    }
}

GET /bookdb_index/book/_search
{
    "_source": ["title"],
    "query": {
        "match_phrase": { "title" : "definitive guide" }
    },
    "highlight" : {
        "number_of_fragments" : 3,
        "fragment_size" : 150,
        "fields" : {
            "title" : { "pre_tags" : [""], "post_tags" : [""] }
          
          }
        }
    } 
}
    
PUT /twitter/_doc/1
{
  "fullname" : "John Doe",
  "text" : "twitter test test test "
}

PUT /twitter/_doc/2
{
  "fullname" : "Jane Doe",
  "text" : "Another twitter test ..."
}

GET /twitter/_termvectors/1
{
  "fields" : ["text"],
  "offsets" : true,
  "payloads" : true,
  "positions" : true,
  "term_statistics" : true,
  "field_statistics" : true
}

GET /twitter/_termvectors
{
  "doc" : {
    "fullname" : "John Doe",
    "text" : "twitter test test test"
  },
  "fields": ["fullname"],
  "per_field_analyzer" : {
    "fullname": "keyword"
  }
}

GET /bookdb_index/book/_bulk
{ "index": { "_id": 5 }}
{ "title": "Solr in Action Solr in Action", "authors": ["trey grainger", "timothy potter"], "summary" : "Comprehensive guide to implementing a scalable search engine using Apache Solr", "publish_date" : "2014-04-05", "num_reviews": 23, "publisher": "manning" }

----------------------------------------------------------------------------

 

PUT /bookdb_index
    { "settings": { "number_of_shards": 1 }}
    
POST /bookdb_index/book/_bulk
    { "index": { "_id": 1 }}
    { "title": "Elasticsearch: The Definitive Guide", "authors": ["clinton gormley", "zachary tong"], "summary" : "A distibuted real-time search and analytics engine", "publish_date" : "2015-02-07", "num_reviews": 20, "publisher": "oreilly" }
    { "index": { "_id": 2 }}
    { "title": "Taming Text: How to Find, Organize, and Manipulate It", "authors": ["grant ingersoll", "thomas morton", "drew farris"], "summary" : "organize text using approaches such as full-text search, proper name recognition, clustering, tagging, information extraction, and summarization", "publish_date" : "2013-01-24", "num_reviews": 12, "publisher": "manning" }
    { "index": { "_id": 3 }}
    { "title": "Elasticsearch in Action", "authors": ["radu gheorge", "matthew lee hinman", "roy russo"], "summary" : "build scalable search applications using Elasticsearch without having to do complex low-level programming or understand advanced data science algorithms", "publish_date" : "2015-12-03", "num_reviews": 18, "publisher": "manning" }
    { "index": { "_id": 4 }}
    { "title": "Solr in Action", "authors": ["trey grainger", "timothy potter"], "summary" : "Comprehensive guide to implementing a scalable search engine using Apache Solr", "publish_date" : "2014-04-05", "num_reviews": 23, "publisher": "manning" }
    
  GET /bookdb_index/book/_search
  {
    "_source": ["title"],
    "query" : {
        "match_phrase" : { "title" : "in action" }
    },
    "highlight" : {
     "pre_tags" : [""],
        "post_tags" : ["
"],
        "fields" : {
            "title" : {
             "fragment_size" : 30, 
             "number_of_fragments" : 10, 
             "type": "experimental",
             "options": {"return_offsets": true}
            }
        },
        "order" : "score"
    }
}

GET /bookdb_index/book/_search
{
    "_source": ["title"],
    "query": {
        "match_phrase": { "title" : "definitive guide" }
    },
    "highlight" : {
        "number_of_fragments" : 3,
        "fragment_size" : 150,
        "fields" : {
            "title" : { "pre_tags" : [""], "post_tags" : [""] }
          
          }
        }
    } 
}

' > elasticsearch' 카테고리의 다른 글

openkoreantext_analyzer start_offset bug  (0) 2019.10.09
한글 형태소 분석기 비교  (0) 2019.07.05
elasticsearch 에 없는 기능 - return terms  (1) 2019.04.26