0

I have set up a full text index on one field using the following apoc query

CALL apoc.index.addAllNodes("CompName", {Basic_company_data:["CompanyName"]})

It seems to create the index correctly. If I then run this query

call apoc.index.search("CompName", "swaythling~") YIELD node as n return n

I get five results, which is expected.

If I then run the same query but with + housing

call apoc.index.search("CompName", "swaythling~ + housing~") YIELD node as n return n

I get 100 nodes returned, not the one node I was expecting. This seems to be the total number of nodes with swaythling OR housing in the company name, when I am trying to get the results for swaythling AND housing.

I can get the correct results by doing two apoc calls but I fell the and is something I should be able to do.

Have I done something wrong in setting up the index or am I missing something from the index search itself?

SAB
  • 175
  • 17
  • 1
    The underlying index is lucene, and I think `+` indicates the next token has to be present, I don't think it means AND. Have you tried using `&&` instead? – InverseFalcon Mar 06 '18 at 08:00
  • No I hadn't tried it and yes it was the answer.. thank you – SAB Mar 06 '18 at 08:02
  • Nice. I added my comment as an answer and linked to the lucene documentation. – InverseFalcon Mar 06 '18 at 08:10
  • FYI: Boolean algebra uses `+` for `OR` and `*` for `AND`. For example `x*y=1` both have to be 1 same in an actual multiplication. This also works for `OR` `x+y>=1` at least one variable has to be 1. – Yoshi Mar 07 '18 at 14:59

1 Answers1

1

The underlying index is lucene, and I think + indicates the next token has to be present, I don't think it means AND. Have you tried using && instead?`

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51