林欣儀
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Solr #### 1. Solr 概要 - 被設計為功能強大的文檔檢索應用程序(或平台),以提供根據用戶查詢所需的數據。 - 是基於Lucene所構建的搜索服務器(Solr底層的核心技術是使用Lucene來實現的)。是一個具備功能管理界面的獨立應用程式,提供給企業能夠應用。 - Lucene: - 是一套Java的全文檢索和搜尋的開放原始碼程式庫(全文搜尋引擎),由Apache軟體基金會支援和提供。 - 提供了一個簡單卻強大的應用程式介面,能夠做*全文檢索,但Lucene不是一個完整的應用程式,而是一個代碼庫和 API。 > *全文檢索:從文字或資料庫中自由萃取出訊息的技術,能夠在大量資料中快速搜索。執行全文檢索任務的程式,一般稱作搜尋引擎。 圖:Solr如何與應用程序整合(同時運作) ![](https://i.imgur.com/FjpGXna.png) >例 : 線上商店應用程序提供用戶界面"購物車",為最終用戶進行購買的方式。而庫存管理應用程序將允許商店員工編輯產品信息。產品的metadata(元資料)將保存在某種數據庫或Solr中。 - 依據以下步驟,Solr將使得online store搜索功能變得容易新增資料: 1. 定義一個schema。該schema告訴Solr有關將要建立索引的文檔的內容。Solr的架構強大而靈活,允許您根據應用程序訂制Solr的行為。(在商店的例子中,該schema將為產品名稱、描述、價格、製造商等定義字段。) 2. 提供documents,讓最終用戶未來可搜索。 3. 在應用程序中公開搜索功能。 --- #### 2. Solr’s Schema File - schema file定義核心中field(字段),儲存有關field的類型和field的詳細信息(index of the field)。 - 該文件的名稱和位置可能會有所不同,具體取決於最初配置Solr的方式或以後對其進行修改的方式。 - Solr中提供了兩種方式來配置schema,兩者只能選一: 1. 預設方式:通過Schema API 來進行配置及更改,資訊儲存在核心目錄的conf/managed-schema(Solr默認使用的檔案)中。可以用"顯式配置託管模式功能"以使用備用文件名,但是Solr仍會自動更新文件的內容。 2. 傳統方式:需手動編輯conf/schema.xml,編輯完後需重新開啟核心才會生效。 --- #### 3. Solr config - 許多文件都是XML格式,但與config進行設定的API傾向於用JSON格式進行programmatic access(編程訪問)。 - 在Solr’s Home將找到以下文件: - solr.xml:指定Solr server instance的configuration options(配置選項)。(更多solr.xml的詳細信息:Solr Cores和solr.xml。) - 每個Solr核心包含: - core.properties:每個核心定義的屬性。例如:名稱、核心所屬集合、Schema的位置等等。 - solrconfig.xml:控制high-level(高端?)行為,包含請求handler(處理程序)和其他配置選項。可定義url(需請求handler),及使用其默認配置以執行plugins。例如:指定data directory(數據目錄)的備用位置。 - managed-schema(或schema.xml):描述向Solr要求搜索至index的文件。該模式將文件定義為field的集合。操作者可以定義field type和field本身。field type的定義功能強大,並包含有關Solr如何處理傳入field values(字段值)和query values(查詢值)的資料。 - data/:包含low-level index files的目錄。 - Solr index配置透過schema.xml和solrconfig.xml完成 : ![](https://i.imgur.com/5W5EYzl.png) > WordPress : 為一套內容管理系統,能夠透過它來快速建立及管理網站。 > Solarium : Solr的用戶端庫 > From : https://deeplearning.lipingyang.org/2017/05/13/apache-solr-schema-explained/ --- #### 4. Solr API Schema API用HTTP API管理Schema的設定,可以讀、寫Schema,並通過API來更新Schema,solr會自動更新核心。用這種方式來動態的定義模式,就不用自己手動編寫config。 但是修改Schema並不會自動重新索引已索引的文件,只會對後續的文件起作用,如果必要的話則需手動重新索引(刪除原來的,再重新提交文件)。 --- # solr 7.4.0 server 安裝 #### 1. download java 14.0.2 Step 1. Installing OpenJDK version 14 on Ubuntu 20.04 LTS ``` $ sudo apt update $ sudo apt upgrade $ sudo apt install openjdk-14-jdk ## for servers try headless version ## $ sudo apt install openjdk-14-jdk-headless ``` Step 2. Verification(check version) ``` $ java --version ``` Step 3. Set up JAVA_HOME environment variable update the environment variables config file ``` $ sudo nano /etc/environment ## OR ## $ sudo vim /etc/environment ``` and set JAVA_HOME as follows: ``` JAVA_HOME="/usr/lib/jvm/java-14-openjdk-amd64" ``` #### 2. solr 7.4.0 server installation Step 1. 取得Solr的下載地址,然後使用wget命令下載 https://archive.apache.org/dist/lucene/solr/ ``` wget https://archive.apache.org/dist/lucene/solr/7.4.0/solr-7.4.0.tgz ``` Step 2. 下載完成後解壓縮檔案 ``` tar -zxvf solr-7.4.0.tgz ``` Step 3. 啟動 ``` cd solr-7.4.0 bin/solr start ``` Then~~~Happy searching! --- # 創建solr core 1. 先在`solr-7.4.0/server/solr/`中創建一個資料夾(例:test1) ![](https://i.imgur.com/lfvJpkv.png) 2. 在test1中複製一個configsets中的conf (提示有說明需存在instanceDir和dataDir 才能create core) ``` cp -r configsets/_default/conf/ test1/ ``` 3. 到Solr Core Admin中點選"Add Core", 將name及instanceDir輸入一開始建立的資料夾名(test1), then the new core(test1) will be created. ![](https://i.imgur.com/uAUTh9q.png) 4. success! ![](https://i.imgur.com/OOgKIRl.png) > 其他方式: https://wbkuo.pixnet.net/blog/post/156101696 --- # 配置schema 1. 到 `solr-7.4.0/server/solr/test1/conf/` 中打開 `managed-schema` 或 `schema.xml` 2. 將[solr7.4 with ckan 2.9 schema](https://hackmd.io/6gveBw5OR2Sgmz1DtiCAbg?view#Solr-74---Ckan-29) 貼上 3. Save it! --- > 有關solr的連結們: > https://wbkuo.pixnet.net/blog/category/2123399 > https://lucene.apache.org/solr/8_7_0/changes/Changes.html --- # Solr upgrade #### Solr 7.4 to 7.5 ##### 1. Schema Changes - 從Solr 7.0開始,Solr的schema field-guessing 已為所有的 ```_txt``` fields 創建 ```_str``` fields, 並在query(查詢)過後 return 這些 fields (by default). 從7.5開始, ```_str``` fields 在 default 不會再 return fields, 但仍可以用, 只是需要透過```fl```(某個參數)來進行查詢. - 從Solr v4開始不再運作的Standard Filter 已被 removed. ##### 2. Index Merge Policy - 使用 TieredMergePolicy (Solr 的default merge policy ) 時, ```optimize``` 以及 ```expungeDeletes``` 將遵循 ```maxMergedSegmentMB``` 的配置參數, 參數的 default 值為 5000 (5GB)。 - 如果絕對有必要控制優化後 segment 的數量, 須把 ```maxSegments```設為正整數。 (盡量把```maxSegments``` 設為高於 ```1``` )。 -  ```TieredMergePolicy``` 會比以前更積極 reclaim(收回) 超出 ```maxMergedSegmentMB``` 部分的resources。 ##### 3. UIMA(Unstructured Information Management Application) Removed - The UIMA contrib 已被永久 removed from Solr > UIMA官網: https://uima.apache.org/ ##### 4. Logging - ```server/resources/log4j2.xml``` 的default位置位於Solr的 logging configuration file 中  - Windows users 的bug已修正: Solr的範例log files(```bin/solr start -e```) 會被放到正確位置 ```example/``` 而不是 ```server``` --- #### Solr 7.5 to 7.6 ##### 1. Collections - 使用CLUSTERPROP命令以設定 cluster-wide default cluster properties 的 JSON 參數已更改。 舊的語法將 defaults nest(崁套)至 ```clusterDefaults```中,而新的語法只使用 ```defaults```. The command to use is still ```set-obj-property``` > nest(崁套): 在已有的表格、圖像或圖層中再加一個或多個表格、圖像或圖層,亦或兩個物體有裝配(可以互相組合)關係時,將一個物體嵌入另一物體的方法。 An example of the new syntax is: (JSON) ``` { "set-obj-property": { "defaults" : { "collection": { "numShards": 2, "nrtReplicas": 1, "tlogReplicas": 1, "pullReplicas": 1 } } } } ``` 到Solr 9之前仍支持舊語法,但建議用戶盡快使用新語法。 - ```min_rf```這個參數已被棄用,不再需要被提供去查看已實現的replication factor(複制因子)。replication factor 將會與 response 一起 return 給客戶端。 ##### 2. Autoscaling - 現在 autoscaling policy 被當作 default strategy, 可選擇創建 (new replicas)新副本 或 新collections副本 上的(node)節點。而所有的users都必須使用 default policy, 在default情況下, 會依據core的數量和可用的freedisk排序nodes, 這表示 "最少core數量和最高可用freedisk的node" 會被優先選擇去創建新的core。 - 以上的更改對 ```maxShardsPerNode``` 參數有兩個影響: 1. 實施 autoscaling policy 時,對```maxShardsPerNode```移除了使用限制, 現在創建collectiong時可設定此參數。 2. 移除 autoscaling policy 的default設定: ```maxShardsPerNode=1```。變成無論是否有設置autoscaling policy, 都會正確設置```maxShardsPerNode```(如果有需要的話)。 ```maxShardsPerNode``` 的default值仍為 ```1```, 但如果需要unlimited的舊行為則把 ```maxSharedsPerNode ```設為-1即可。. ##### 3. DirectoryFactory - Lucene 引入 ```ByteBuffersDirectoryFactory``` 以代替 ```RAMDirectoryFactory```( ```RAMDirectoryFactory``` 在Solr 9中會被移除)。 - 雖然現在仍然鼓勵users使用 ```NRTCachingDirectoryFactory```(可允許 Lucene 選擇最佳的 directory factory 來使用), 但如果已明確使用 ```RAMDirectoryFactory``` 來配置 Solr 的話, 建議在Solr 9 發布前更改至新的替代方式。 --- #### Solr 7.6 to 7.7 ##### 1. Admin UI - Admin UI 現在會顯示一個 login 畫面讓在 cluster (集群)中的 users 進行身分驗證。 - 有 Basic Authentication 的 clusters 會提示 users 輸入他們的 username and password. 在 clusters 使用 Kerberos Authentication  進行配置並指導 users 去配置它們的 browser 以提供適當的Kerberos ticket。 - login 畫面是裝飾用的, Admin UI 主要目的在於觸發 Solr requests, 使 7.7 以前版本的user能夠進行身分驗證且確認至今仍在使用。 ##### 2. Distributed Requests - 由於安全考量, ```shards``` 這個參數接收 distributed requests 時需手動選擇 shards 和 replicas, 以根據可接受值的whitelist(白名單) 檢查(or核對?) nodes。 - 在 SolrCloud mode 中, whitelist 會自動配置所有 live nodes。在 standalone mode(獨立模式)的 default 中, whitelist 是空的。 - 在 standalone mode 中使用 ```shards``` 參數的 users 可透過 ```solrconfig.xml``` 中的任何 ```shardHandler``` 中的```shardsWhitelist```property 來更改此值。 --- #### Solr 7.4 升級至 7.7 直接安裝solr 7.7, 創建core(參考[這裡](https://hackmd.io/aW45G9nhQ-GdCzNXgylN1A?both#%E5%89%B5%E5%BB%BAsolr-core))之後配置schema: 1. 到 `solr-7.7.0/server/solr/test1/conf/` 中打開 `managed-schema` 或 `schema.xml` 2. 將[solr7.4 with ckan 2.9 schema](https://hackmd.io/6gveBw5OR2Sgmz1DtiCAbg?view#Solr-74---Ckan-29) 貼上。 3. 存檔後即可和ckan連接使用。 --- # 目前ckan 2.9 - solr 7.7的問題 #### 1. 依照格式或標籤進行篩選 > 20210416測試時可以正常篩選 (1) 一個資料集如果有兩(或以上)個檔案的話無法依格式分類,但只有一個檔案的話可以。 (2) 可以手動設定標籤,但無法進行篩選。 #### 2. 模糊搜尋 > (英文字不分大小寫皆可搜尋, 例: 搜尋"aids"等同於搜尋"AIDS") > (中文斷詞目前好像是依照字和字之間有沒有空白分辨的, 例: "檔 案"的"檔"與"案"是分開的兩個詞, "檔案"則是同一個詞) ##### (1) 資料集標題及敘述, 檔案名稱及敘述的搜尋: "2016" - 2016腸病毒 "腸病毒" - 2016腸病毒 "16腸病毒" - 2016腸病毒 "area" - Area, Age, and Gender Statistical table - AIDS (中文敘述之間無空白) - Area, Age, and Gender Statistical table - AIDS - v2 (中文敘述之間有空白) "AIDS" - aids_diagnose - Area, Age, and Gender Statistical table - AIDS - Area, Age, and Gender Statistical table - AIDS - v2 - 愛滋病感染死亡人數統計 "愛滋病" - aids_diagnose - Area, Age, and Gender Statistical table - AIDS - v2 - 愛滋病感染死亡人數統計 "die" - 愛滋病感染死亡人數統計 (在檔案標題中找到) "統計表" - Area, Age, and Gender Statistical table - AIDS - v2 "資料集" - (沒有結果) "資 料 集" - 2 0 1 6 腸 病 毒 (在資料集敘述中找到) "有" - 2 0 1 6 腸 病 毒 (在檔案敘述中找到) "檔 案" - 2 0 1 6 腸 病 毒 (在檔案敘述中找到) ##### (2) 用副檔名搜尋: "csv" - 可搜尋副檔名為"csv"的資料 "json" - 可搜尋副檔名為"json"的資料 ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully