Error rendering WebPanel: No renderer found for resource type: velocity Template contents: <meta name="ajs-keyboardshortcut-hash" content="$keyboardShortcutManager.shortcutsHash">

버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

코드 블럭
collapsetrue
GET /books/_search
{
  "query" : {
    "term" : { "author" : "william" }
  },
  "highlight" : {
    "pre_tags" : ["<strong>"], //강조 태그 지정, 지정 안하면 <em></em>으로 강조됨
    "post_tags" : ["</strong>"],
    "fields" : { "author" : { } }
  },
  "size": 1,
  "_source": "author"
}


/*결과*/
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 6,
    "max_score" : 1.261305,
    "hits" : [
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "09SqcmkBavgQMwrCKCm0",
        "_score" : 1.261305,
        "_source" : {
          "author" : "William Shakespeare"
        },
        "highlight" : {
          "author" : [
            "<strong>William</strong> Shakespeare"
          ]
        }
      }
    ]
  }
}



Search Template

  • 검색 시 template을 지정해서 파라미터 형식으로 넘겨줄 수 있음
코드 블럭
collapsetrue
GET /_search/template
{
    "source" : {
      "query": { "match" : { "{{my_field}}" : "{{my_value}}" } },
      "size" : "{{my_size}}"
    },
    "params" : {
        "my_field" : "title",
        "my_value" : "the",
        "my_size" : 5
    }
}


/*결과*/
{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 59,
    "successful" : 58,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 11,
    "max_score" : 0.8142733,
    "hits" : [
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "1NSqcmkBavgQMwrCKCm0",
        "_score" : 0.8142733,
        "_source" : {
          "title" : "The Adventures of Tom Sawyer",
          "author" : "Mark Twain",
          "category" : "Folk",
          "written" : "1876-03-01T01:34:00",
          "pages" : 220,
          "sell" : 83200000,
          "plot" : """Tom Sawyer lives with his Aunt Polly and his half-brother, Sid. Tom dirties his clothes in a fight and is made to whitewash the fence the next day, as a punishment. He cleverly persuades his friends to trade him small treasures for the privilege of doing his work. He trades the treasures for Sunday School tickets which one normally receives for memorizing scriptures, redeeming them for a bible, much to the surprise and bewilderment of the superintendent who thought "it was simply preposterous that this boy had warehoused two thousand sheaves of Scriptural wisdom on his premises—a dozen would strain his capacity, without a doubt.""""
        }
      },
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "19SqcmkBavgQMwrCKCm0",
        "_score" : 0.35667494,
        "_source" : {
          "title" : "The Three Musketeers",
          "author" : "Alexandre Dumas",
          "category" : "Historical novel",
          "written" : "1844-10-01T12:00:00",
          "pages" : 340,
          "sell" : 61400000,
          "plot" : "In 1625 France, d'Artagnan—a poor young nobleman—leaves his family in Gascony and travels to Paris with the intention of joining the Musketeers of the Guard. However, en route, at an inn in Meung-sur-Loire, an older man derides d'Artagnan's horse and, feeling insulted, d'Artagnan demands to fight a duel with him. The older man's companions beat d'Artagnan unconscious with a pot and a metal tong that breaks his sword. His letter of introduction to Monsieur de Tréville, the commander of the Musketeers, is stolen. D'Artagnan resolves to avenge himself upon the man, who is later revealed to be the Comte de Rochefort, an agent of Cardinal Richelieu, who is in Meung to pass orders from the Cardinal to Milady de Winter, another of his agents."
        }
      },
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "2dSqcmkBavgQMwrCKCm0",
        "_score" : 0.35667494,
        "_source" : {
          "title" : "The Invisible Man",
          "author" : "H. G. Wells",
          "category" : [
            "Horror",
            "Science fiction novel"
          ],
          "written" : "1897-05-01T07:32:00",
          "pages" : 210,
          "sell" : 67800000,
          "plot" : "A mysterious stranger, Griffin, arrives at the local inn of the English village of Iping, West Sussex, during a snowstorm. The stranger wears a long-sleeved, thick coat and gloves, his face hidden entirely by bandages except for a fake pink nose, and a wide-brimmed hat. He is excessively reclusive, irascible, and unfriendly. He demands to be left alone and spends most of his time in his rooms working with a set of chemicals and laboratory apparatus, only venturing out at night. While staying at the inn, hundreds of strange glass bottles arrive that Griffin calls his luggage. Many local townspeople believe this to be very strange. He becomes the talk of the village (one of the novel's most charming aspects is its portrayal of small-town life in southern England, which the author knew from first-hand experience)."
        }
      },
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "29SqcmkBavgQMwrCKCm0",
        "_score" : 0.3503948,
        "_source" : {
          "title" : "Journey to the Center of the Earth",
          "author" : "Jules Verne",
          "category" : [
            "Science fiction",
            "adventure novel"
          ],
          "written" : "1864-07-01T11:30:00",
          "pages" : 212,
          "sell" : 42100000,
          "plot" : "Professor Lidenbrock decides to lock everyone in the house and force himself and the others (Axel, and the maid, Martha) to go without food until he cracks the code. Axel discovers the answer when fanning himself with the deciphered text: Lidenbrock's decipherment was correct, and only needs to be read backwards to reveal sentences written in rough Latin."
        }
      },
      {
        "_index" : "books",
        "_type" : "book",
        "_id" : "z9SqcmkBavgQMwrCKCm0",
        "_score" : 0.30873197,
        "_source" : {
          "title" : "The Merchant of Venice",
          "author" : "William Shakespeare",
          "category" : "Comedies",
          "written" : "1596-02-01T04:42:00",
          "pages" : 97,
          "sell" : 124100000,
          "plot" : "Bassanio, a young Venetian of noble rank, wishes to woo the beautiful and wealthy heiress Portia of Belmont. Having squandered his estate, he needs 3,000 ducats to subsidise his expenditures as a suitor. Bassanio approaches his friend Antonio, a wealthy merchant of Venice who has previously and repeatedly bailed him out. Antonio agrees, but since he is cash-poor – his ships and merchandise are busy at sea – he promises to cover a bond if Bassanio can find a lender, so Bassanio turns to the Jewish moneylender Shylock and names Antonio as the loan's guarantor."
        }
      }
    ]
  }
}



Search Shards API

  • shards의 정보를 검색하기 위한 API

코드 블럭
GET /twitter/_search_shards


/*결과*/
{
  "nodes" : {
    "AvZ4mIRYTvWXyVmL2gxvKg" : {
      "name" : "AvZ4mIR",
      "ephemeral_id" : "WmsE6_QmQUKIWIHN8tr8Og",
      "transport_address" : "127.0.0.1:9300",
      "attributes" : {
        "ml.machine_memory" : "17179869184",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      }
    }
  },
  "indices" : {
    "twitter" : { }
  },
  "shards" : [
    [
      {
        "state" : "STARTED",
        "primary" : true,
        "node" : "AvZ4mIRYTvWXyVmL2gxvKg",
        "relocating_node" : null,
        "shard" : 0,
        "index" : "twitter",
        "allocation_id" : {
          "id" : "LX5roCiBSfuTzKUi68Dxfw"
        }
      }
    ],
    [
      {
        "state" : "STARTED",
        "primary" : true,
        "node" : "AvZ4mIRYTvWXyVmL2gxvKg",
        "relocating_node" : null,
        "shard" : 1,
        "index" : "twitter",
        "allocation_id" : {
          "id" : "Y8yJ5th4SNSJs9x0Aw4faA"
        }
      }
    ],
    [
      {
        "state" : "STARTED",
        "primary" : true,
        "node" : "AvZ4mIRYTvWXyVmL2gxvKg",
        "relocating_node" : null,
        "shard" : 2,
        "index" : "twitter",
        "allocation_id" : {
          "id" : "12ukbIKtSxiIK2jw4N7Kcg"
        }
      }
    ],
    [
      {
        "state" : "STARTED",
        "primary" : true,
        "node" : "AvZ4mIRYTvWXyVmL2gxvKg",
        "relocating_node" : null,
        "shard" : 3,
        "index" : "twitter",
        "allocation_id" : {
          "id" : "feyi3bKHRZOtOone2gvmSg"
        }
      }
    ],
    [
      {
        "state" : "STARTED",
        "primary" : true,
        "node" : "AvZ4mIRYTvWXyVmL2gxvKg",
        "relocating_node" : null,
        "shard" : 4,
        "index" : "twitter",
        "allocation_id" : {
          "id" : "AmCtpfelTPiUzWluVsBLBg"
        }
      }
    ]
  ]
}



참고링크