Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to integrate Vector field. #1278

Closed
Rjtsahu opened this issue Nov 25, 2019 · 2 comments
Closed

Need help to integrate Vector field. #1278

Rjtsahu opened this issue Nov 25, 2019 · 2 comments

Comments

@Rjtsahu
Copy link

Rjtsahu commented Nov 25, 2019

I am trying to create a field of type dense_vector but as it is not available in current releases.

so had created a VectorField class which extends CustomFields , with it's base_type as :

class VectorField(CustomField):
    name = 'dense_vector'
    builtin_type = 'dense_vector'

class MyDocument(Document):
    vector_data = VectorField()

MyDocument.init()

but when i am running this code i am getting mapping error:
RequestError(400, 'mapper_parsing_exception', 'The [dims] property must be specified for field [vector].')

This is because the properties doesn't have dims specified.

Mapping :

"mappings": {
    "properties": {
      "vector_data": {
        "type": "dense_vector",
        "dims": 3
      }
    }
  }

can some one suggest how to pass [dims] in field property ?

@ksrvtsa
Copy link

ksrvtsa commented Jan 13, 2020

This should work!

class DenseVector(Field):
    name = 'dense_vector'

    def __init__(self, dims):
         super(DenseVector, self).__init__(dims=dims)

@Rjtsahu
Copy link
Author

Rjtsahu commented Jan 13, 2020

cool, i ll check this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants