中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

企業(yè)建網(wǎng)站能不能一次進(jìn)費用九幺seo優(yōu)化神器

企業(yè)建網(wǎng)站能不能一次進(jìn)費用,九幺seo優(yōu)化神器,培訓(xùn)網(wǎng)站建設(shè)學(xué)校,中國手機最好的網(wǎng)站排名搭建自己的搜索引擎——oh-my-search使用 使用elasticsearch和search-ui搭建自己的搜索引擎,快速查找資源和文件。如果對代碼感興趣,相關(guān)代碼已在github上開源,歡迎fork代碼。 搭建elasticsearch 先搭建eleasticsearch再搭建kibana 搭建e…

搭建自己的搜索引擎——oh-my-search使用

使用elasticsearch和search-ui搭建自己的搜索引擎,快速查找資源和文件。如果對代碼感興趣,相關(guān)代碼已在github上開源,歡迎fork代碼。

搭建elasticsearch

先搭建eleasticsearch再搭建kibana

搭建elasticsearch
mkdir elasticsarch
cd elasticsarch
mkdir -p /es/plugins
mkdir -p /es/data
mkdir -p /es/logs
mkdir -p /es/config
vim docker-compose.yml

編輯docker-compose.yml文件,內(nèi)容如下:

version: '3'
services:elasticsearch:image: elasticsearch:8.9.0container_name: elasticsearchprivileged: trueenvironment:- "cluster.name=elasticsearch" #設(shè)置集群名稱為elasticsearch- "discovery.type=single-node" #以單一節(jié)點模式啟動- "ES_JAVA_OPTS=-Xms512m -Xmx1096m" #設(shè)置使用jvm內(nèi)存大小- bootstrap.memory_lock=truevolumes:- ./es/plugins:/usr/share/elasticsearch/plugins #插件文件掛載- ./es/data:/usr/share/elasticsearch/data:rw #數(shù)據(jù)文件掛載- ./es/logs:/usr/share/elasticsearch/logs:rw- ./es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.ymlports:- 9200:9200- 9300:9300deploy:resources:limits:cpus: "2"memory: 1000Mreservations:memory: 200M

其中./es/config/elasticsearch.yml的內(nèi)容如下,可按需修改:

cluster.name: "elasticsearch"
network.host: 0.0.0.0
  • 啟動elasticsearch

配置完成后,啟動elasticsearch。

docker-compose --compatibility up -d

同時進(jìn)入elasticsearch容器內(nèi)部,修改密碼。

# 進(jìn)入容器內(nèi)部
docker exec -it elasticsearch bash
# 修改密碼
elasticsearch@4c37fcfb6f13:~$ ls
LICENSE.txt  NOTICE.txt  README.asciidoc  bin  config  data  jdk  lib  logs  modules  plugins
elasticsearch@4c37fcfb6f13:~$ bin/elasticsearch-reset-password --username elastic -i
bin/elasticsearch-reset-password --username kibana -i
搭建kibana
mkdir kibana
cd kibana
vim docker-compose.yml

docker-compose.yml的內(nèi)容如下:

version: '3'
services:kibana:image: kibana:8.9.0container_name: kibanavolumes:- ./kibana.yml:/usr/share/kibana/config/kibana.ymlports:- 5601:5601deploy:resources:limits:cpus: "1"memory: 1000Mreservations:memory: 200M

kibana.yml的文件內(nèi)容如下,可按需修改:

elasticsearch.hosts: http://elasticsearch:9200
elasticsearch.username: kibana
elasticsearch.password: kibana
server.host: "0.0.0.0"
server.name: kibana
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: zh-CN

啟動kibana,

docker-compose --compatibility up -d

同時搭建eleasticsearch和kibana

  • 使用docker-compose啟動elasticsearch

編輯docker-compose.yml文件,內(nèi)容如下:

version: '3'
services:elasticsearch:image: elasticsearch:8.9.0container_name: elasticsearchprivileged: trueenvironment:- "cluster.name=elasticsearch" #設(shè)置集群名稱為elasticsearch- "discovery.type=single-node" #以單一節(jié)點模式啟動- "ES_JAVA_OPTS=-Xms512m -Xmx1096m" #設(shè)置使用jvm內(nèi)存大小- bootstrap.memory_lock=truevolumes:- ./es/plugins:/usr/local/dockercompose/elasticsearch/plugins #插件文件掛載- ./es/data:/usr/local/dockercompose/elasticsearch/data:rw #數(shù)據(jù)文件掛載- ./es/logs:/usr/local/dockercompose/elasticsearch/logs:rwports:- 9200:9200- 9300:9300deploy:resources:limits:cpus: "2"memory: 1000Mreservations:memory: 200Mkibana:image: kibana:8.9.0container_name: kibanadepends_on:- elasticsearch #kibana在elasticsearch啟動之后再啟動volumes:- ./es/config/kibana:/usr/share/kibana/config/kibana.yamlports:- 5601:5601

其中kibana.yaml的內(nèi)容如下:

elasticsearch.hosts: http://elasticsearch:9200
server.host: "0.0.0.0"
server.name: kibana
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: zh-CN
  • 進(jìn)入elasticsearch終端,修改elasticsearch密碼
# 進(jìn)入容器內(nèi)部
docker exec -it elasticsearch bash
# 修改密碼
elasticsearch@4c37fcfb6f13:~$ ls
LICENSE.txt  NOTICE.txt  README.asciidoc  bin  config  data  jdk  lib  logs  modules  plugins
elasticsearch@4c37fcfb6f13:~$ bin/elasticsearch-reset-password --username elastic -i
WARNING: Owner of file [/usr/share/elasticsearch/config/users] used to be [root], but now is [elasticsearch]
WARNING: Owner of file [/usr/share/elasticsearch/config/users_roles] used to be [root], but now is [elasticsearch]
This tool will reset the password of the [elastic] user.
You will be prompted to enter the password.
Please confirm that you would like to continue [y/N]yEnter password for [elastic]: 
Re-enter password for [elastic]: 
Password for the [elastic] user successfully reset.
elasticsearch@4c37fcfb6f13:~$
  • 生成kibana的token
# 重啟容器然后進(jìn)入容器內(nèi)部生成kibana的token
docker exec -it elasticsearch bash
elasticsearch@4c37fcfb6f13:~$ bin/elasticsearch-create-enrollment-token -s kibana
  • 獲取kibana驗證碼
# 在瀏覽器打開http://ip:5601,粘貼kibana的token,然后進(jìn)入kibana容器內(nèi)部獲取驗證碼
sudo docker exec -it kibana bash       
kibana@fce2ab8aec1e:~$ ls
LICENSE.txt  NOTICE.txt  README.txt  bin  config  data  logs  node  node_modules  package.json  packages  plugins  src  x-pack
kibana@fce2ab8aec1e:~$ bin/kibana-verification-code 
Your verification code is:  042 943 

搭建search-ui

  • 創(chuàng)建search-ui項目
npm install -g  create-react-app
# 創(chuàng)建名為doc_index的項目
create-react-app doc_index --use-npm
cd doc_index
npm install --save @elastic/react-search-ui @elastic/search-ui-app-search-connector @elastic/search-ui-elasticsearch-connector
  • 啟動search-ui項目
npm start
  • 創(chuàng)建api_key

登錄kibana,進(jìn)入到/app/management/security/api_keys/,創(chuàng)建一個api_key并記錄api_key.

  • 創(chuàng)建索引

登錄kibana的dev_tools創(chuàng)建和設(shè)置索引:

# 創(chuàng)建索引
PUT /doc_index# 設(shè)置索引屬性
PUT /doc_index/_mapping
{"properties":{"title":{"type":"text","fields":{"suggest": {"type": "search_as_you_type"}}},"category":{"type":"text"},"url":{"type":"text"}}
}# 設(shè)置查詢返回的最大條數(shù)
PUT /doc_index/_settings
{"index" : {"max_result_window": 500000}
}
  • 導(dǎo)入數(shù)據(jù)
# 插入單條數(shù)據(jù)
POST /doc_index/_bulk
{"index":{}}
{"title":"test","category":"test","url":"http://localhost:3000"}## 批量插入
POST /doc_index/_bulk
{"index":{}}
{"title":"test2","category":"test","url":"http://localhost:3001"}
{"index":{}}
{"title":"dir","category":"test","url":"http://localhost:3002"}
{"index":{}}
{"title":"ddssd","category":"test","url":"http://localhost:3003"}
{"index":{}}
{"title":"測試","category":"test","url":"http://localhost:3004"}

當(dāng)然也可以用命令行插入,如使用curl命令:

curl --username username:password -H "Content-Type: application/json" -XPOST  192.168.56.130:9200/bank/account/_bulk?pretty --data-binary "@test.json"

其中–username指定elasticsearch的用戶名和密碼,test.json的內(nèi)容如下:

{"index":{}}
{"title":"test2","category":"test","url":"http://localhost:3001"}
{"index":{}}
{"title":"dir","category":"test","url":"http://localhost:3002"}
{"index":{}}
{"title":"ddssd","category":"test","url":"http://localhost:3003"}
{"index":{}}
{"title":"測試","category":"test","url":"http://localhost:3004"}

完整數(shù)據(jù)插入命令如下:


PUT /doc_index/_mapping
{"properties":{"title":{"type":"text","fields":{"suggest": {"type": "search_as_you_type"}}},"category":{"type":"text"},"url":{"type":"text"}}
}PUT /doc_index/_settings
{"index" : {"max_result_window": 500000}
}GET /doc_index/_searchPOST /doc_index/_bulk
{"index":{}}
{"title":"test2","category":"test","url":"http://localhost:3001"}
{"index":{}}
{"title":"dir","category":"test","url":"http://localhost:3002"}
{"index":{}}
{"title":"ddssd","category":"test","url":"http://localhost:3003"}
{"index":{}}
{"title":"測試","category":"test","url":"http://localhost:3004"}

完善search-ui

search-ui下載下來之后,還沒有綁定數(shù)據(jù),此時還需要修改app.js來進(jìn)行適配。

app.js需更改成:

// Step #1, import statements
import React from "react";
// 這里需要注意app和網(wǎng)頁的接口名稱不一樣
import ElasticsearchAPIConnector from "@elastic/search-ui-elasticsearch-connector";
import {PagingInfo,ResultsPerPage,Paging,SearchProvider,Results,SearchBox,Sorting
} from "@elastic/react-search-ui";
import { Layout } from "@elastic/react-search-ui-views";
import "@elastic/react-search-ui-views/lib/styles/styles.css";// Step #2, The connector
const connector = new ElasticsearchAPIConnector({host: "http://elasticsearch:9200", // elasticsearch的地址apiKey: "WjUxNVpZc0JTb3pYN2J6cEdqRHQ6R3Y0all0R1dTai1LSjhqMGc5THFVdw==", // elasticsearch 的登錄秘鑰,在kibana上生成index: "doc_index" // 要訪問的索引的地址
});// Step #3: Configuration options
const configurationOptions = {searchQuery: {search_fields: {title: {weight: 3},url: {},category: {}},result_fields: {title: {snippet: {}},url: {snippet: {}},category: {snippet: {}}}},apiConnector: connector,alwaysSearchOnInitialLoad: true
};// step4 show result 
export default function App() {return (<SearchProvider config={configurationOptions}><div className="App"><Layoutheader={<SearchBox />}// 要展示的標(biāo)題和標(biāo)題對應(yīng)的連接bodyContent={<Results titleField="title" urlField="url" />}bodyHeader={<><PagingInfo /><ResultsPerPage /></>}bodyFooter={<Paging />}/></div></SearchProvider>);
}

還可以修改一下public下面的title標(biāo)簽,修改成自己的項目標(biāo)簽。如:

<title>doc_index</title>
http://www.risenshineclean.com/news/50123.html

相關(guān)文章:

  • 合肥建站企業(yè)百度指數(shù)的數(shù)據(jù)怎么導(dǎo)出
  • 怎樣做網(wǎng)站編輯校園推廣方案
  • 提供營銷網(wǎng)站建設(shè)公司百度推廣收費標(biāo)準(zhǔn)
  • 鄭州鄭州網(wǎng)站建設(shè)河南做網(wǎng)站公司哪家好seo建站還有市場嗎
  • 衡水專業(yè)網(wǎng)站制作seo搜索引擎優(yōu)化崗位要求
  • 上饒建設(shè)培訓(xùn)中心網(wǎng)站圖片外鏈生成
  • 蘭州網(wǎng)站建設(shè)招聘信息策劃公司
  • 網(wǎng)頁制作背景圖代碼杭州seo網(wǎng)站建設(shè)
  • 在家做網(wǎng)站查網(wǎng)址
  • 查詢商品價格走勢的網(wǎng)站自己建網(wǎng)站怎么弄
  • 網(wǎng)站微信認(rèn)證費用多少錢八上數(shù)學(xué)優(yōu)化設(shè)計答案
  • seo做的不好的網(wǎng)站免費網(wǎng)絡(luò)推廣平臺
  • r6300v2做網(wǎng)站搜索排名廣告營銷
  • 做出口網(wǎng)站鄭州新聞發(fā)布
  • 建設(shè)工程材料網(wǎng)站百度seo怎么優(yōu)化
  • 做廚柜有招聘網(wǎng)站嗎seo網(wǎng)站關(guān)鍵字優(yōu)化
  • 紙牌網(wǎng)站建設(shè)德陽seo
  • 網(wǎng)頁設(shè)計的注意事項網(wǎng)絡(luò)網(wǎng)站推廣優(yōu)化
  • 怎么在programmableweb 網(wǎng)站做api分析圖表深圳百度國際大廈
  • 所有做網(wǎng)站公司營銷廣告文案
  • 外貿(mào)網(wǎng)站該怎么做營銷存在的問題及改進(jìn)
  • 爾雅網(wǎng)站開發(fā)實戰(zhàn)百度站長工具網(wǎng)站提交
  • 廣告公司做的網(wǎng)站字體侵權(quán)武漢seo首頁
  • 美國做deals的網(wǎng)站中山百度推廣公司
  • 吉林省水土保持生態(tài)建設(shè)網(wǎng)站網(wǎng)站seo優(yōu)化方案設(shè)計
  • 關(guān)于做網(wǎng)站的調(diào)查問卷外包公司
  • 鎮(zhèn)江疫情最新數(shù)據(jù)seo免費外鏈工具
  • 相親網(wǎng)與做網(wǎng)站廣州關(guān)鍵詞搜索排名
  • 網(wǎng)站建設(shè)初期工作方案網(wǎng)絡(luò)推廣項目代理
  • 廣州做企業(yè)網(wǎng)站找哪家公司好網(wǎng)絡(luò)營銷推廣方法和手段