<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ElasticSearch アーカイブ - Sheltie&#039;s Garage</title>
	<atom:link href="https://sheltie-garage.xyz/category/%E6%8A%80%E8%A1%93%E7%B3%BB/elasticsearch/feed/" rel="self" type="application/rss+xml" />
	<link>https://sheltie-garage.xyz/category/技術系/elasticsearch/</link>
	<description>趣味に生きる</description>
	<lastBuildDate>Sun, 14 Nov 2021 12:41:22 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://sheltie-garage.xyz/wp-content/uploads/2018/04/cropped-L927xrpq-32x32.jpg</url>
	<title>ElasticSearch アーカイブ - Sheltie&#039;s Garage</title>
	<link>https://sheltie-garage.xyz/category/技術系/elasticsearch/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>kotlin + Springbootでelasticsearchを使ってみる</title>
		<link>https://sheltie-garage.xyz/2021/11/kotlin-springboot%e3%81%a7elasticsearch%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 14 Nov 2021 12:41:22 +0000</pubDate>
				<category><![CDATA[ElasticSearch]]></category>
		<category><![CDATA[Kotlin]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=2975</guid>

					<description><![CDATA[<p>Dアニメを数ヶ月前に契約しました。月々500円位で最新作から懐かしのアニメまで好きな時間に見れるので重宝してます。欲を言えば、過激な作品はTV版と同じように規制がかかっているものがあるので、解除されていればより良かったの [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2021/11/kotlin-springboot%e3%81%a7elasticsearch%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/">kotlin + Springbootでelasticsearchを使ってみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>Dアニメを数ヶ月前に契約しました。月々500円位で最新作から懐かしのアニメまで好きな時間に見れるので重宝してます。欲を言えば、過激な作品はTV版と同じように規制がかかっているものがあるので、解除されていればより良かったのですが・・・</p>



<h2 class="wp-block-heading">ただ、検索機能に不満あり</h2>



<p>一般的なキーワードサーチ、あいうえお順、大まかな作品ジャンルは検索機能としてあるのですが、例えば人気順の並べ替えや、あらすじ内のキーワード検索、キャラクタの容姿 etcのような検索機能は、見た感じ準備されていません。</p>



<p>不思議なのは、内部的にデータを持っているので、もっといろいろな作品の見せ方ができるはずなのに、それをやっていないことです。</p>



<h2 class="wp-block-heading">なので、勉強がてら作り始めました</h2>



<p>Dアニメをもっと楽しみたいので自分仕様の検索機能を作ることにしました。<br>スクレイピングを行いDアニメの作品をelasticsearchに登録、kotlin + Springbootの構成で組むことにしました。</p>



<h2 class="wp-block-heading">SpringbootからElasticsearchに検索を行う</h2>



<p>ここからやっと本題です。Springbootからelasticsearchに対して検索をかけます。手順は以下の通り。</p>



<p><strong>依存関係に以下を追加</strong></p>



<pre class="crayon-plain-tag">dependencies {
	implementation(&quot;org.springframework.data:spring-data-elasticsearch:4.1.7&quot;)
	・・・
}</pre>



<p><strong>リポジトリクラスを作成</strong></p>



<pre class="crayon-plain-tag">package xyz.sheltiegarage.dAnimeApi.repository

import org.springframework.data.domain.PageRequest
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
import xyz.sheltiegarage.dAnimeApi.data.DAnimeData

interface DAnimeRepository : ElasticsearchRepository&amp;lt;DAnimeData, Int&gt; {
}</pre>



<p><strong>データクラスを追加</strong></p>



<pre class="crayon-plain-tag">package xyz.sheltiegarage.dAnimeApi.data

import org.springframework.data.annotation.Id
import org.springframework.data.elasticsearch.annotations.Document
import org.springframework.data.elasticsearch.annotations.Field

@Document(indexName = &quot;d_anime&quot;)
data class DAnimeData(
    @Id
    @Field(name=&quot;work_id&quot;)
    val workId: Int,
    @Field(name=&quot;work_title&quot;)
    val workTitle: String,
    @Field(name=&quot;link&quot;)
    val link: String,
    @Field(name=&quot;main_key_visual_path&quot;)
    val mainKeyVisualPath: String,
    @Field(name=&quot;main_key_visual_alt&quot;)
    val mainKeyVisualAlt: String,
    @Field(name=&quot;my_list_count&quot;)
    val myListCount: Int,
    @Field(name=&quot;favorite_count&quot;)
    val favoriteCount: Int
)</pre>



<p><strong>サーチメソッドを呼び出し</strong></p>



<pre class="crayon-plain-tag">@RestController
class SearchController(val dAnimeRepository: DAnimeRepository) {

    @GetMapping(&quot;/search&quot;)
    fun getAll() :List&amp;lt;DAnimeData&gt; {

        val data: List&amp;lt;DAnimeData&gt; = dAnimeRepository.findAll(Sort.by(Sort.Order.desc(&quot;favorite_count&quot;))).toList()

        return data
    }
}</pre>



<p><strong>application.propertiesに設定を追加</strong></p>



<pre class="crayon-plain-tag">spring.elasticsearch.rest.uris=localhost:9200</pre>



<p>参考にしたのは以下のサイトです<br><a rel="noreferrer noopener" href="https://raphaeldelio.medium.com/how-to-connect-elasticsearch-to-kotlin-using-spring-boot-spring-data-and-ssl-f261a08727d8" target="_blank">https://raphaeldelio.medium.com/how-to-connect-elasticsearch-to-kotlin-using-spring-boot-spring-data-and-ssl-f261a08727d8</a></p>



<p>リポジトリクラスを作成することで自動的に「selectAll（全検索）」といった基本的な検索が行なえます。リポジトリクラスは「メソッド名に基づき検索を行う」ことができるため、メソッド名の規約さえ守れば、メソッドの実装を行わずに検索を行うことができるので便利ですね。詳細は以下からご確認ください。<br><a href="https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.query-methods" target="_blank" rel="noreferrer noopener">https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.query-methods</a></p>



<h2 class="wp-block-heading">複雑な検索はどうする？</h2>



<p>上記のクエリメソッドを利用すれば検索は行なえますが、例えば「お気に入りが1000以上、声優にに「長縄」を含む、配信終了間近の作品」といったような複雑な検索を行う場合、クエリメソッドの仕組みでは対応できないため、別の検索手段を探す必要があります。その方法は・・・只今調査中です。（https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.operations.queries あたりを使えばできそうな気がするが・・・）</p>



<h2 class="wp-block-heading">以上</h2>



<p>雑な解説ですが、以上です。なぜなら自分もまだちゃんと理解していないから、きちんとした説明が行えないのです。とにかくkotlin + Springboot + elasticsearchの情報が少なく、何をするにも詰まってしまいますが、自分仕様の検索システムができるまでコツコツ開発は続けようと思っています。</p>



<p>お気に入り順に並び替えてみると「呪術廻戦」って「鬼滅の刃」超えのお気に入り登録数なのですね。無職転生やスライムなども人気が高いですね</p>



<a href="https://www.amazon.co.jp/%E9%AB%98%E9%80%9F%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%A9%E3%83%96%E3%83%AB%E6%A4%9C%E7%B4%A2%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3-ElasticSearch-Server-%E3%82%A2%E3%82%B9%E3%82%AD%E3%83%BC%E6%9B%B8%E7%B1%8D-%EF%BC%B2%EF%BD%81%EF%BD%86%EF%BD%81%EF%BD%8C-%EF%BC%AB%EF%BD%95%EF%BD%83-%EF%BC%88%EF%BD%8C%E3%81%AB%E3%82%B9%E3%83%88%E3%83%AD%E3%83%BC%E3%82%AF%E7%AC%A6%E5%8F%B7%E3%80%81%EF%BD%83%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%B5%E3%83%B3%E3%83%BB%E3%83%86%E3%82%AE%E3%83%A5%E4%BB%98%E3%81%8F%EF%BC%89-ebook/dp/B00J4KDYZU?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&#038;crid=3RRCD2YX6AYX3&#038;keywords=elasticsearch&#038;qid=1636893548&#038;sprefix=elasticsearch%2Caps%2C264&#038;sr=8-9&#038;linkCode=li2&#038;tag=monodon-22&#038;linkId=ca910045f31a6980d89ccefc8561d291&#038;language=ja_JP&#038;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" border="0" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&#038;ASIN=B00J4KDYZU&#038;Format=_SL160_&#038;ID=AsinImage&#038;MarketPlace=JP&#038;ServiceVersion=20070822&#038;WS=1&#038;tag=monodon-22&#038;language=ja_JP" ></a><img decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&#038;language=ja_JP&#038;l=li2&#038;o=9&#038;a=B00J4KDYZU" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
<a href="https://www.amazon.co.jp/%E5%9F%BA%E7%A4%8E%E3%81%8B%E3%82%89%E3%82%8F%E3%81%8B%E3%82%8B-Kotlin-%E5%AF%8C%E7%94%B0%E5%81%A5%E4%BA%8C-ebook/dp/B0956X1Z8Z?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&#038;keywords=kotlin&#038;qid=1636893577&#038;sr=8-7&#038;linkCode=li2&#038;tag=monodon-22&#038;linkId=8aa2ff05f3055a1ee4577ba9272a9031&#038;language=ja_JP&#038;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" border="0" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&#038;ASIN=B0956X1Z8Z&#038;Format=_SL160_&#038;ID=AsinImage&#038;MarketPlace=JP&#038;ServiceVersion=20070822&#038;WS=1&#038;tag=monodon-22&#038;language=ja_JP" ></a><img decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&#038;language=ja_JP&#038;l=li2&#038;o=9&#038;a=B0956X1Z8Z" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
<a href="https://www.amazon.co.jp/Spring%E5%BE%B9%E5%BA%95%E5%85%A5%E9%96%80-Spring-Framework%E3%81%AB%E3%82%88%E3%82%8BJava%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%96%8B%E7%99%BA-%E6%A0%AA%E5%BC%8F%E4%BC%9A%E7%A4%BENTT%E3%83%87%E3%83%BC%E3%82%BF-ebook/dp/B01IEWNLBU?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&#038;keywords=spring+boot&#038;qid=1636893608&#038;sr=8-6&#038;linkCode=li2&#038;tag=monodon-22&#038;linkId=a326291cb2f22d72ff3fad684a0d977c&#038;language=ja_JP&#038;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" border="0" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&#038;ASIN=B01IEWNLBU&#038;Format=_SL160_&#038;ID=AsinImage&#038;MarketPlace=JP&#038;ServiceVersion=20070822&#038;WS=1&#038;tag=monodon-22&#038;language=ja_JP" ></a><img decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&#038;language=ja_JP&#038;l=li2&#038;o=9&#038;a=B01IEWNLBU" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
<p>投稿 <a href="https://sheltie-garage.xyz/2021/11/kotlin-springboot%e3%81%a7elasticsearch%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/">kotlin + Springbootでelasticsearchを使ってみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Elasticvueを使ってみる</title>
		<link>https://sheltie-garage.xyz/2021/09/elasticvue%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sat, 18 Sep 2021 10:36:23 +0000</pubDate>
				<category><![CDATA[ElasticSearch]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=2880</guid>

					<description><![CDATA[<p>前回でlaradockに付属しているelasticsearchを起動するところまでおこなてみました。が、やっぱりGUIで色々管理できたほうが便利ということで、elasticsearchのGUI管理ツールを探したところ「e [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2021/09/elasticvue%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/">Elasticvueを使ってみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>前回でlaradockに付属しているelasticsearchを起動するところまでおこなてみました。<br>が、やっぱりGUIで色々管理できたほうが便利ということで、elasticsearchのGUI管理ツールを探したところ<br>「elasticvue」というツールが見つかったので使ってみることにしました。</p>



<h2 class="wp-block-heading">Docker版を使ってみる</h2>



<p>公式ページにいろいろなタイプ（ブラウザエクステンション、Docker、バイナリなど）が提供されているので、お好きなものをどうぞ<br><a href="https://elasticvue.com/" target="_blank" rel="noreferrer noopener">https://elasticvue.com/</a></p>



<p>自分はDocker版を利用することにしました。</p>



<h2 class="wp-block-heading">起動からアクセスまで</h2>



<p>公式ページにDockerの起動コマンドが書いてあるので使用します<br>(自分の環境では8080ポートが使用されていたため、8880ポートで起動しています)</p>



<pre class="crayon-plain-tag">docker run -p 8880:8080 \
           -d cars10/elasticvue</pre>



<p>コンテナ起動後は「http://localhost:8880」で管理画面にアクセスできます</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="481" src="https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-1024x481.png" alt="" class="wp-image-2883" srcset="https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-1024x481.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-300x141.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-768x361.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-1536x721.png 1536w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/b79cfa052a5528238bf63d825409613a-2048x962.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">CORSの設定が必要</h2>



<p>elasticvueのページにアクセスすると「最初にCORSの設定が必要」という注意書きが出てきますので、設定します。<br>設定先はlaradockのelasticsearchになります。elasticsearchもDockerで起動しているので、コンテナに入って作業します。</p>



<pre class="crayon-plain-tag">% docker-compose exec elasticsearch bash
-- ここからコンテナ内での操作 --
&amp;#91;root@1f4250529341 config]# pwd
/usr/share/elasticsearch/config
&amp;#91;root@1f4250529341 config]# vi elasticsearch.yml
  以下2行を追加
  http.cors.enabled: true
  http.cors.allow-origin: &quot;http://localhost:8880&quot;</pre>



<p>ファイル保存後、コンテナから抜けてdocker-composeからコンテナの再起動をかけました</p>



<pre class="crayon-plain-tag">% docker-compose restart</pre>



<p>再度 elasticvueの管理画面にアクセスし、TEST CONNECTIONをクリックします。<br>接続に成功すれば右下に「SUCCESS」を表示されます。<br>次に「CONNECT」ボタンを押してelasticsearchに接続します</p>



<h2 class="wp-block-heading">elasticvueでできること</h2>



<p>elasticsearchに接続できると、ノードやクラスターのヘルスやインデックス一覧が確認できます。<br>REST APIへアクセスするためのエディタも準備されており、簡単なドキュメントの管理もできそう</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="554" src="https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c-1024x554.png" alt="" class="wp-image-2884" srcset="https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c-1024x554.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c-300x162.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c-768x416.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c-1536x831.png 1536w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/3c9f551fa1aa31796cd402cba149000c.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="950" src="https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca-1024x950.png" alt="" class="wp-image-2885" srcset="https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca-1024x950.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca-300x278.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca-768x712.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca-1536x1425.png 1536w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/a9b6bd2a388ea333cbde6938098ccdca.png 1962w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>ただ、GUIを使用してインデックスの追加や、マッピングの定義は行えないようで、それらの設定は自分でJSONを作ってREST API経由でリクエストを行う必要があるみたい・・・</p>



<h2 class="wp-block-heading">以上</h2>



<p>elasticvueの紹介でした。サクッとelasticseearchの状態を確認するには良さそうですが、本格的に管理/運用を行うなら、もう少し機能が充実したツールを探す必要がありそうですね。<br>自分の場合、あくまで個人開発なので、とりあえずelasticvueを使ってドキュメント作成や管理を進めていこうと思います</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2021/09/elasticvue%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b/">Elasticvueを使ってみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>とりあえずElasticSearchを始めてみる</title>
		<link>https://sheltie-garage.xyz/2021/09/%e3%81%a8%e3%82%8a%e3%81%82%e3%81%88%e3%81%9aelasticsearch%e3%82%92%e5%a7%8b%e3%82%81%e3%81%a6%e3%81%bf%e3%82%8b/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 12 Sep 2021 05:53:54 +0000</pubDate>
				<category><![CDATA[ElasticSearch]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=2868</guid>

					<description><![CDATA[<p>全文検索エンジンにElasticSearchを使ってみます 今まで全文検索エンジンはSolr派だったのですが、トレンドでいうとElasticSearchのほうが世界的には人気のようで・・・　ということで勉強も兼ねて、今回 [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2021/09/%e3%81%a8%e3%82%8a%e3%81%82%e3%81%88%e3%81%9aelasticsearch%e3%82%92%e5%a7%8b%e3%82%81%e3%81%a6%e3%81%bf%e3%82%8b/">とりあえずElasticSearchを始めてみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">全文検索エンジンにElasticSearchを使ってみます</h2>



<p>今まで全文検索エンジンはSolr派だったのですが、トレンドでいうとElasticSearchのほうが世界的には人気のようで・・・　ということで勉強も兼ねて、今回は全文検索エンジンにElasticSearchを使ってみようと思います。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="782" src="https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-1024x782.png" alt="" class="wp-image-2869" srcset="https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-1024x782.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-300x229.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-768x587.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-1536x1174.png 1536w, https://sheltie-garage.xyz/wp-content/uploads/2021/09/d8977ae88245bf91b670f0227664d264-2048x1565.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">ElasticSearchにIndexを作成する</h2>



<p>Solrの場合、コマンドを実行することでコア(index)を作成しますが、ElasticSearcの場合、HTTP-APIにリクエストを投げて作るようなので、公式ページにある以下のコマンドを実行</p>



<pre class="crayon-plain-tag">% docker-compose up -d elasticsearch</pre>



<p>上記のコマンドでElasticSearchを起動して</p>



<pre class="crayon-plain-tag">curl -X PUT &quot;http://localhost:9200/d_anime&quot;</pre>



<p>上記のコマンドでコアを作成できます</p>



<h2 class="wp-block-heading">とりあえず動作確認</h2>



<pre class="crayon-plain-tag">http:&amp;#47;&amp;#47;localhost:9200/d_anime/</pre>



<p>結果</p>



<pre class="crayon-plain-tag">{
  &quot;d_anime&quot;: {
    &quot;aliases&quot;: {},
    &quot;mappings&quot;: {},
    &quot;settings&quot;: {
      &quot;index&quot;: {
        &quot;creation_date&quot;: &quot;1631425258572&quot;,
        &quot;number_of_shards&quot;: &quot;1&quot;,
        &quot;number_of_replicas&quot;: &quot;1&quot;,
        &quot;uuid&quot;: &quot;7jtaoMllRkGOpTKATtC2UA&quot;,
        &quot;version&quot;: {
          &quot;created&quot;: &quot;7090199&quot;
        },
        &quot;provided_name&quot;: &quot;d_anime&quot;
      }
    }
  }
}</pre>



<p>ひとまずインデックスは作成されました。<br>次は検索結果</p>



<pre class="crayon-plain-tag">http:&amp;#47;&amp;#47;localhost:9200/d_anime/_search</pre>



<p>結果</p>



<pre class="crayon-plain-tag">{
  &quot;took&quot;: 5,
  &quot;timed_out&quot;: false,
  &quot;_shards&quot;: {
    &quot;total&quot;: 1,
    &quot;successful&quot;: 1,
    &quot;skipped&quot;: 0,
    &quot;failed&quot;: 0
  },
  &quot;hits&quot;: {
    &quot;total&quot;: {
      &quot;value&quot;: 0,
      &quot;relation&quot;: &quot;eq&quot;
    },
    &quot;max_score&quot;: null,
    &quot;hits&quot;: &amp;#91;]
  }
}</pre>



<p>まだ中身が空っぽなのでデータの返却はないですが、人まずは検索が動いているようです。</p>



<h2 class="wp-block-heading">とりあえず以上です</h2>



<p>ひとまずElasticSearchが動いたところまで確認できました。本当はlogstashを利用したデータ取り込みまでやってみたかったのですが、理解が追いつかず、次回に持ち越しです・・・</p>



<a href="https://www.amazon.co.jp/Elasticsearch%E5%AE%9F%E8%B7%B5%E3%82%AC%E3%82%A4%E3%83%89-impress-top-gear%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA-%E6%83%A3%E9%81%93-ebook/dp/B07DN87LQV?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;dchild=1&amp;keywords=elasticsearch&amp;qid=1631425960&amp;sr=8-5&amp;linkCode=li2&amp;tag=monodon-22&amp;linkId=093f495ec885eae571b135af178220eb&amp;language=ja_JP&amp;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;ASIN=B07DN87LQV&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=monodon-22&amp;language=ja_JP" border="0"></a><img loading="lazy" decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&amp;language=ja_JP&amp;l=li2&amp;o=9&amp;a=B07DN87LQV" alt="" style="border:none !important; margin:0px !important;" width="1" height="1" border="0">
<a href="https://www.amazon.co.jp/%E9%AB%98%E9%80%9F%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%A9%E3%83%96%E3%83%AB%E6%A4%9C%E7%B4%A2%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3-ElasticSearch-Server-%E3%82%A2%E3%82%B9%E3%82%AD%E3%83%BC%E6%9B%B8%E7%B1%8D-%EF%BC%B2%EF%BD%81%EF%BD%86%EF%BD%81%EF%BD%8C-%EF%BC%AB%EF%BD%95%EF%BD%83-%EF%BC%88%EF%BD%8C%E3%81%AB%E3%82%B9%E3%83%88%E3%83%AD%E3%83%BC%E3%82%AF%E7%AC%A6%E5%8F%B7%E3%80%81%EF%BD%83%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%B5%E3%83%B3%E3%83%BB%E3%83%86%E3%82%AE%E3%83%A5%E4%BB%98%E3%81%8F%EF%BC%89-ebook/dp/B00J4KDYZU?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;dchild=1&amp;keywords=elasticsearch&amp;qid=1631425960&amp;sr=8-8&amp;linkCode=li2&amp;tag=monodon-22&amp;linkId=83424f105af6640cf57de6f47c1302c8&amp;language=ja_JP&amp;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;ASIN=B00J4KDYZU&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=monodon-22&amp;language=ja_JP" border="0"></a><img loading="lazy" decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&amp;language=ja_JP&amp;l=li2&amp;o=9&amp;a=B00J4KDYZU" alt="" style="border:none !important; margin:0px !important;" width="1" height="1" border="0">
<a href="https://www.amazon.co.jp/%E3%83%87%E3%83%BC%E3%82%BF%E5%88%86%E6%9E%90%E5%9F%BA%E7%9B%A4%E6%A7%8B%E7%AF%89%E5%85%A5%E9%96%80%EF%BC%BBFluentd%EF%BC%8CElasticsearch%EF%BC%8CKibana%E3%81%AB%E3%82%88%E3%82%8B%E3%83%AD%E3%82%B0%E5%8F%8E%E9%9B%86%E3%81%A8%E5%8F%AF%E8%A6%96%E5%8C%96%EF%BC%BD-%E9%88%B4%E6%9C%A8-%E5%81%A5%E5%A4%AA-ebook/dp/B075RTZ141?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;dchild=1&amp;keywords=elasticsearch&amp;qid=1631425960&amp;sr=8-9&amp;linkCode=li2&amp;tag=monodon-22&amp;linkId=a04e00899641daff17d8ccd8ee9ef891&amp;language=ja_JP&amp;ref_=as_li_ss_il" target="_blank" rel="noopener"><img decoding="async" src="//ws-fe.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;ASIN=B075RTZ141&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=monodon-22&amp;language=ja_JP" border="0"></a><img loading="lazy" decoding="async" src="https://ir-jp.amazon-adsystem.com/e/ir?t=monodon-22&amp;language=ja_JP&amp;l=li2&amp;o=9&amp;a=B075RTZ141" alt="" style="border:none !important; margin:0px !important;" width="1" height="1" border="0">
<p>投稿 <a href="https://sheltie-garage.xyz/2021/09/%e3%81%a8%e3%82%8a%e3%81%82%e3%81%88%e3%81%9aelasticsearch%e3%82%92%e5%a7%8b%e3%82%81%e3%81%a6%e3%81%bf%e3%82%8b/">とりあえずElasticSearchを始めてみる</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
