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

Creating an arangoSearchView does not set the properties #621

Closed
mfusser opened this issue Aug 26, 2019 · 5 comments · Fixed by #622
Closed

Creating an arangoSearchView does not set the properties #621

mfusser opened this issue Aug 26, 2019 · 5 comments · Fixed by #622
Assignees
Labels
Bug A code defect that needs to be fixed.

Comments

@mfusser
Copy link

mfusser commented Aug 26, 2019

Hi,
I am having a problem when creating ArangoSearch-Views via arangojs.
When I provide an "ArangoSearchViewPropertiesOptions" object it gets ignored and no properties get set.
If i use the setProperties command afterwards with the same "ArangoSearchViewPropertiesOptions" object i can set the properties without any problems.

The problem with this though is that the "primarySort" property that was added in 3.5 can only be set during creation of the view.

I used the following Code to replicate the issue:

var arangojs = require("arangojs");
var db = new arangojs.Database();

async function run() {
    db.useDatabase('cruddl');
    var view = db.arangoSearchView('xyz');
    let properties = {
        commitIntervalMsec: 123,
        links: {
            heroes: {
                includeAllFields: true
            }
        }
    };
    var x = await view.create(properties);
    console.log(x)
// view.setProperties(properties);
}

run();

I used arangojs 6.11.0 and arangodb 3.5.0 for the replication, although i had the same issue with arangojs 6.10.0 and arangodb 3.4.7.

Am I doing something wrong, or might this be a bug?

@mfusser
Copy link
Author

mfusser commented Aug 26, 2019

I just checked the Source Code, and I am not 100% sure but maybe the following code in "src/view.ts"

create(
    properties: ArangoSearchViewPropertiesOptions = {}
  ): Promise<ArangoSearchViewPropertiesResponse> {
    return this._connection.request(
      {
        method: "POST",
        path: "/_api/view",
        body: {
          properties,
          name: this.name,
          type: this.type
        }
      },
      res => res.body
    );
  }

should be

create(
    properties: ArangoSearchViewPropertiesOptions = {}
  ): Promise<ArangoSearchViewPropertiesResponse> {
    return this._connection.request(
      {
        method: "POST",
        path: "/_api/view",
        body: {
          ...properties,  // this line was changed
          name: this.name,
          type: this.type
        }
      },
      res => res.body
    );
  }

so it matches the specification (https://www.arangodb.com/docs/stable/http/views-arangosearch.html)

@pluma
Copy link
Contributor

pluma commented Aug 26, 2019

Weird. I guess this may have been the result of a change between an early development version of the Views API and the final GA. I'm fairly certain we did test for this at some point and it worked at the time.

Thanks for reporting. This looks like a bug.

@pluma pluma added the Bug A code defect that needs to be fixed. label Aug 26, 2019
@pluma pluma self-assigned this Aug 26, 2019
@Simran-B
Copy link
Contributor

The ArangoSearch docs were wrong in multiple places about this. It looked like an object with an attribute properties would be required. There are still error messages implying the same. I corrected the docs for v3.5.0: https://www.arangodb.com/docs/stable/arangosearch-views.html#view-definitionmodification

pluma added a commit that referenced this issue Aug 27, 2019
pluma added a commit that referenced this issue Aug 27, 2019
pluma added a commit that referenced this issue Aug 27, 2019
@mfusser
Copy link
Author

mfusser commented Aug 29, 2019

Thanks for the fix. Will there be a release including this soon? Without this fix we cannot use primarySort as it can only be set during view-creation.

@pluma
Copy link
Contributor

pluma commented Aug 30, 2019

There's a new bugfix release 6.11.1 out which contains the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A code defect that needs to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants