安装Elasticsearch的knn插件时出现错误。

huangapple go评论60阅读模式
英文:

error in installing knn plugin for elasticsearch

问题

我正在尝试安装KNN插件以使以下代码正常工作:

from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
es = Elasticsearch('http://127.0.0.1:9200', verify_certs=False)
settings={
    "settings":{
        "index": {
            "knn": "true",
            "knn.space_type": "cosinesimil"
        }   
    },
    "mappings":{
        "dynamic": "true",
        "_source":{
            "enabled":"true"
        },
        "properties":{
            "vector": {
                "type": "knn_vector",
                "dimension": "768"
            }
        }
    }
}

es.indices.create(index = 'document_embeddings', ignore=[400,404], body = settings)

但是我收到以下错误:

{'error': {'root_cause': [{'type': 'illegal_argument_exception',
    'reason': 'unknown setting [index.knn] please check that any required plugins are installed, or check the breaking changes documentation for removed settings'}],
  'type': 'illegal_argument_exception',
  'reason': 'unknown setting [index.knn] please check that any required plugins are installed, or check the breaking changes documentation for removed settings',
  'suppressed': [{'type': 'illegal_argument_exception',
    'reason': 'unknown setting [index.knn.space_type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings'}]},
 'status': 400}

我认为问题是KNN插件未安装,因此我正在以下方式安装,其中zip文件从这里下载:

-> Installing file://elastiknn-8.6.1.0.zip
-> Downloading file://elastiknn-8.6.1.0.zip
-> Failed installing file://elastiknn-8.6.1.0.zip
-> Rolling back file://elastiknn-8.6.1.0.zip
-> Rolled back file://elastiknn-8.6.1.0.zip
Exception in thread "main" java.net.UnknownHostException: elastiknn-8.6.1.0.zip
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:560)
	at java.base/java.net.Socket.connect(Socket.java:666)
...

我运行的安装插件的命令是:

sudo bin/elasticsearch-plugin install file://elastiknn-8.6.1.0.zip

我的elasticsearch版本是8.6.1,看起来与elastiknn版本完全兼容。请问有人能告诉我如何在我的mac上设置KNN插件与elasticsearch一起使用吗?谢谢! 1: https://github.com/alexklibisz/elastiknn/releases/tag/8.6.1.0-MAIN1517-SNAPSHOT

英文:

I am trying to install the KNN plugin to get the following code working:

from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
es = Elasticsearch('http://127.0.0.1:9200',verify_certs=False)
settings={
    "settings":{
     "index": {
      "knn": "true",
      "knn.space_type": "cosinesimil"
    }   
    },
    "mappings":{
        "dynamic": "true",
        "_source":{
            "enabled":"true"
        },
    "properties":{
        "vector": {
            "type": "knn_vector",
            "dimension": "768"
        }
    }
    }
}

es.indices.create(index = 'document_embeddings', ignore=[400,404], body = settings)

but am getting the following error:

{'error': {'root_cause': [{'type': 'illegal_argument_exception',
    'reason': 'unknown setting [index.knn] please check that any required plugins are installed, or check the breaking changes documentation for removed settings'}],
  'type': 'illegal_argument_exception',
  'reason': 'unknown setting [index.knn] please check that any required plugins are installed, or check the breaking changes documentation for removed settings',
  'suppressed': [{'type': 'illegal_argument_exception',
    'reason': 'unknown setting [index.knn.space_type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings'}]},
 'status': 400}

I think the cause is that the KNN plugin is not installed, so I am installing it in the following way where thee zip file is downloaded from here.

-> Installing file://elastiknn-8.6.1.0.zip
-> Downloading file://elastiknn-8.6.1.0.zip
-> Failed installing file://elastiknn-8.6.1.0.zip
-> Rolling back file://elastiknn-8.6.1.0.zip
-> Rolled back file://elastiknn-8.6.1.0.zip
Exception in thread "main" java.net.UnknownHostException: elastiknn-8.6.1.0.zip
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:560)
	at java.base/java.net.Socket.connect(Socket.java:666)
	at java.base/sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:1045)
	at java.base/sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:1010)
	at java.base/sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1102)
	at java.base/sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1088)
	at java.base/sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:318)
	at java.base/sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:424)
	at org.elasticsearch.plugins.cli.InstallPluginAction.downloadZip(InstallPluginAction.java:465)
	at org.elasticsearch.plugins.cli.InstallPluginAction.download(InstallPluginAction.java:329)
	at org.elasticsearch.plugins.cli.InstallPluginAction.execute(InstallPluginAction.java:247)
	at org.elasticsearch.plugins.cli.InstallPluginCommand.execute(InstallPluginCommand.java:89)
	at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
	at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:94)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
	at org.elasticsearch.cli.Command.main(Command.java:50)
	at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)

The command that I am running to install the plugin is:

sudo bin/elasticsearch-plugin install file://elastiknn-8.6.1.0.zip

The version of my elasticsearch i.e. 8.6.1 seems perfectly compatible with that of elastiknn. Can anyone please tell me how can I get a working setup of KNN with elasticsearch in my mac? Thanks!

答案1

得分: 0

使用类型为密集向量的索引。阅读此文档

英文:

Use type dense vector. Read this documentation.

huangapple
  • 本文由 发表于 2023年2月10日 05:51:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75404791.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定