datalevin

simongray 2025-05-02T11:21:52.575759Z

How do you do phrase searches in Datalog? I read the search doc (https://github.com/juji-io/datalevin/blob/master/doc/search.md) but that only mentions how to do it in the search syntax DSL. I have my own working implementation, but I would like to use the built-in one, especially if I can combine it with boolean expressions (which also only seem to be for the special search DSL?). And sorry for only checking out the new capabilities now, @huahaiy !

Huahai 2025-05-06T15:21:44.534629Z

That’s not a phrase if it has stop words in it. “a” is a stop word. What you see is entirely expected

Huahai 2025-05-06T15:24:32.056579Z

Phrase should not contain stop words

simongray 2025-05-06T15:44:01.299929Z

Hmm ok. I guess I could go without stop words then?

simongray 2025-05-06T15:44:52.587429Z

And why do both "had a" and "a little" both work then? It doesn't really seem consistent.

simongray 2025-05-06T15:45:39.520789Z

Seems more like a bug to me 🤷‍♂️

Huahai 2025-05-06T15:45:56.454099Z

"had a" is "had", "a little" is "little", both are single word

Huahai 2025-05-06T15:46:23.507309Z

single word will match.

simongray 2025-05-06T15:46:46.124919Z

Ok, so it automatically reduces into a single word if the edge is a stop word?

Huahai 2025-05-06T15:47:08.232219Z

stop words are removed

simongray 2025-05-06T15:47:43.095719Z

Aha, now I get it.

simongray 2025-05-06T15:48:15.214329Z

Thanks for explaining. I'll have to build some kind of workaround.

Huahai 2025-05-06T15:48:51.110929Z

you can supply your own analyzer

Huahai 2025-05-02T21:02:23.964569Z

The search DSL is just a boolean search expression, where phrase search is just one of its features. fulltext function takes such an expression as the query. A string query is just a special case.

Huahai 2025-05-02T21:02:51.125769Z

What's the question?

Huahai 2025-05-02T21:04:40.205029Z

Oh, you mean the Datalog search example in the doc is not the same as the standalone search one. It is the same. Just replace "red fox" with a search expression. It works.

Huahai 2025-05-02T21:05:06.161709Z

Let me update the doc.

Huahai 2025-05-02T21:31:14.996839Z

Please see the updated doc.

Huahai 2025-05-02T21:31:31.722739Z

It also shows the domain semantics.

Huahai 2025-05-02T21:32:36.332099Z

phrase search requires :index-position? to be true

simongray 2025-05-03T04:35:08.091349Z

Thanks, @huahaiy, I'll try that out 🙏

simongray 2025-05-05T08:38:59.748739Z

The second example query in the search doc returns the empty set on my machine, not #{[2 :text "Mary had a little lamb whose fleece was red as fire."]} . Hmmm? 🤔 I am Datalevin 0.9.22.

simongray 2025-05-06T06:41:41.637099Z

Ah, I think it might have something to do with the fact that an old temp db wasn’t removed prior to running the code. I see that in your test code it is a randomly generated dir, that is the only real difference I can spot.

simongray 2025-05-06T06:55:01.530139Z

I am running into other issues though. The phrase "had a little" doesn’t return any results, for example, while "a little lamb" does. I was thinking maybe this was stopword-related, but "a little" and "had a" both return results.