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

Unable to get a record by filter 'contains' if bin array includes > 1 element #623

Open
Ivan-Ratkin opened this issue Jun 27, 2024 · 0 comments

Comments

@Ivan-Ratkin
Copy link

Ivan-Ratkin commented Jun 27, 2024

Hello!

I encountered an unusual issue. I’m not sure if it’s a bug or if I’m mistaken, but I would appreciate some clarification :)

Code to reproduce:

const Aerospike = require('aerospike');
const client = Aerospike.client({
  hosts: AEROSPIKE_HOST
});

async function connect () {
  await client.connect();
  var index = {
    ns: 'test',
    set: 'demo',
    bin: 'tags',
    index: 'tags_idx',
    type: Aerospike.indexType.LIST,
    datatype: Aerospike.indexDataType.STRING
  }
  await client.createIndex(index)
  const key1 = new Aerospike.Key('test', 'demo', 'key1');
  const key2 = new Aerospike.Key('test', 'demo', 'key2');
  const key3 = new Aerospike.Key('test', 'demo', 'key3');

  const record1 = {
    key: 'key1',
    tags: ['tag1'],
    data: 'wow'
  };

  const record2 = {
    key: 'key2',
    tags: ['tag2'],
    data: 'wow2'
  };

  const record3 = {
    key: 'key3',
    tags: ['tag1, tag2'],
    data: 'wow3'
  };

  await client.put(key1, record1);
  await client.put(key2, record2);
  await client.put(key3, record3);

  const query = client.query('test', 'demo');
  query.select('tags')
  query.where(Aerospike.filter.contains('tags', 'tag1', Aerospike.indexType.LIST))
  const queryStream = await query.results();
  console.log(queryStream.map(res => console.log(res.bins)))
}
connect()

EXPECTED: an array of 2 records with keys key1 and key3
CURRENT: only 1 record with ley key1

I’m not sure why this is happening. If the array includes 1 element, contains works well. But if the array has more than 1 element, contains doesn’t recognize that this record should be returned.
Can you help me with this, please?

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

1 participant