Fork me on GitHub
R.A. Porter15:03:22

I’m currently writing a ticket for my project, in advance of the next Crux release, to update a few of our queries that currently use eql/project. Is the new pull going to be considered more stable going forward or is it slated to be alpha and subject to change again? If it’s the former, I’ll just plan on us fixing/tweaking it for the new api; if the latter, then I at least want to consider the option of removing the use of project/pull from queries so we don’t churn on future updates.


Hey @U01GXCWSRMW we're definitely dropping the "ALPHA" warning with the rename, as per you should be able depend on it more even more confidently 🙂

R.A. Porter17:03:14

Awesome! Can’t wait for the new release!

☺️ 3

@U899JBRPF Any idea when the next release will be? Looks like lots of changes since the last one…


The timetable is currently looking like Wednesday or Thursday next week - although I can't confirm until Tuesday. Not long though!

👍 3

Hello! I'm playing with the lucene search (great feature btw! 🙂), and having some issues. Not sure if this should work:

(defn lucene-text-query [title]
    (crux/db (-> system :db :db))
    '{:find [?e ?s ?t]
      :in [?q]
      :where [[(lucene-text-search "mext.headline\\/title:%s" ?q) [[?e ?s]]]
              [?e :mext.headline/title ?t]]
      :order-by [[?s :desc]]}


(it doesn't)


neither does the following, I would expect that it should, but maybe I'm wrong:


(defn lucene-text-query [title]
    (crux/db (-> system :db :db))
    '{:find [?e ?s ?t]
      :in [?q]
      :where [[(lucene-text-search "mext.headline\\/title:%s" "cov*") [[?e ?s]]]
              [?e :mext.headline/title ?t]]
      :order-by [[?s :desc]]}


just ignore ?q in this case and passing the value. The doc says it will be passed via format


the query does work if I do the formatting before the param is passed to the query, which is what I would do anyway:


(defn lucene-text-query [title]
    (crux/db (-> system :db :db))
    '{:find [?e ?s ?t]
      :in [?q]
      :where [[(lucene-text-search ?q) [[?e ?s]]]
              [?e :mext.headline/title ?t]]
      :order-by [[?s :desc]]}
    (format "mext.headline\\/title:%s" title)))


was just curious if the other cases should or shouldn't work

Steven Deobald20:03:36

I had initially tried the Lucene multi-field stuff before switching to wildcard and I had a similar issue (though I wasn't sure if it was the way I was using it or not)... from what I remember of digging through the Lucene docs, that Lucene multi-field string is surprisingly finicky.

Steven Deobald20:03:12

The test doesn't actually cover the internal formatting case described in the docs, I just noticed:


thanks! yes, I also had to consult the test cases to resolve this.

Steven Deobald18:03:42

Did you find a test case that provided you an example that helped you get the built-in formatter to work?


I thought it's just the standard clojure format (and I guess it is) but you are right, there is no tests that covers the same example that exist in the docs


Hey @U050BA9V5 thanks for reporting this, I've now fixed it ahead of the new release today 🙂


hello! nice! thanks! btw, I had noticed also something weird when was playing with this. Didn't had the time to dig deeper into it so will just quickly explain it before I forget. I was poking with this for a few hours on a db that had really not much data , but I noticed my disk led constantly flashing, and I realized that it was this java process that was doing constantly I/O. This process had around 10G of I/O over a few hours, and I just had 30-50 documents with a few fields. Didn't seem normal 🙂


Oh, hmm, that does sound weird! Which OS are you using? Is that with Rocks for tx-log and doc-store?


I'm on Arch linux. It's Rocks for index and postgres for tx and doc stores. I only noticed that when was poking with the text search.


ok I ran the project again and I see that this happens when I reset my system.


Exception in thread "crux-polling-tx-consumer" java.nio.channels.ClosedByInterruptException
	at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(
	at java.base/
	at java.base/
	at org.apache.lucene.index.SegmentInfos.write(
	at org.apache.lucene.index.SegmentInfos.prepareCommit(
	at org.apache.lucene.index.IndexWriter.startCommit(
	at org.apache.lucene.index.IndexWriter.prepareCommitInternal(
	at org.apache.lucene.index.IndexWriter.commitInternal(
	at org.apache.lucene.index.IndexWriter.shutdown(
	at org.apache.lucene.index.IndexWriter.close(
	at crux.lucene$__GT_lucene_store$fn__6357.invoke(lucene.clj:239)
	at crux.bus.EventBus$fn__19497.invoke(bus.clj:104)
	at crux.lucene$$reify__6355.execute(lucene.clj:237)
	at crux.bus.EventBus.send(bus.clj:104)
	at crux.tx.InFlightTx.commit(tx.clj:343)
	at crux.tx$index_tx_log$fn__20371$fn__20376.invoke(tx.clj:440)
	at crux.tx$index_tx_log$fn__20371.invoke(tx.clj:429)
	at crux.tx$index_tx_log.invokeStatic(tx.clj:421)
	at crux.tx$index_tx_log.invoke(tx.clj:419)
	at crux.tx$__GT_polling_tx_consumer$fn__20392.invoke(tx.clj:464)
	at java.base/
	Suppressed: org.apache.lucene.util.ThreadInterruptedException: java.lang.InterruptedException
		at org.apache.lucene.index.IndexWriter$EventQueue.close(
		at org.apache.lucene.index.IndexWriter.rollbackInternalNoCommit(
		at org.apache.lucene.index.IndexWriter.rollbackInternal(
		at org.apache.lucene.index.IndexWriter.shutdown(
		... 14 more
	Caused by: java.lang.InterruptedException
		at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(
		at java.base/java.util.concurrent.Semaphore.acquire(
		at org.apache.lucene.index.IndexWriter$EventQueue.close(
		... 17 more


(when I start the system initially is ok, this happens after the reset)


thanks for sharing that detail. It might now be resolved by this change I made anyway


if you have 5m spare you could try to test against the latest dev-SNAPSHOT we released yesterday, but no pressure 🙂


I'll give it a spin 🙂 is changing just the lucene dependency ok?


I think that would work yep, but it's safest to change all of the Crux deps


ok, let me do that then


no, it's the same


damn, thanks for trying though. I'll try to repro this today. Can you .close the node before doing the reset as a workaround?


did it give the ~same stack trace btw?


it didn't crashed


let me try it a few more times


I'm closing the node already


ah! now it's hanging


when I do the reset 🙂


this project is open source and it should be relatively easy to bootstrap: if that saves you some time in order to set things up.

🙏 3

btw, that's a toy - almost like a scratchpad - project, I just do experimentation on it 🙂

Steven Deobald15:03:56

> disk led constantly flashing That caught me off guard, leading me to realize I haven't actually had a desktop computer in a decade. 😳

🙂 3
R.A. Porter21:03:23

Playing around with crux-sql for the first time today and I’m curious if there’s a way to work around a data problem. The query in the :crux.sql.table/query needs to include all the attributes of the document I want to express out in the :crux.sql.table/columns but if I have some records that don’t have one of the columns, they get excluded from the results. Makes perfect sense. I’m not surprised it would do that, since my datalog query doesn’t match the entity. But nullable data is pretty common in sql-land. I’m admittedly still quite weak at datalog and still feeling my way around with Crux so maybe there’s a simple or clever solution to this. Or maybe not?


That's right, the SQL columns require there to be some value in the index under the given attribute, so you would need to explicitly store nil if you want the entity to appear in the table. The nil values are then treated the same as SQL's NULL, see This is pretty much the case for modelling with Datalog also, i.e. explicitly storing nils is usually the right strategy. Otherwise certain shapes of queries can require ~exhaustive scanning of indexes

R.A. Porter00:03:36

Makes sense. And workable. Thanks.


> This is pretty much the case for modelling with Datalog also, i.e. explicitly storing nils is usually the right strategy. Otherwise certain shapes of queries can require ~exhaustive scanning of indexes (edited) that's surprising, I thought clojure usually doesn't like to model data this way. Could you give an example of a query that would cause scanning?


This is fast, when explicit nils are stored, because it can lookup the :att nil combination in the AVE index:

{:find [e]
 :where [[e :att nil]]}
However this version, where nils are in the documents or indexes, has to scan through all e's to look for ones that don't contain :att values
{:find [e]
 :where [[e :crux.db/id]
         (not [e :att])]}


ah, right, if you want to explicitly ask questions about the absence of data


@U899JBRPF is binding to nil supposed to work? It seems like it is equivalent to not including the clause at all:

(c/q (:app.crux/node integrant.repl.state/system)
                                            '{:find  [?link]
                                              :in    [x]
                                              :where [[?e2 :embed/content x]
                                                      [?e2 :embed/id ?link]]}
returns empty set, while
(c/q (:app.crux/node integrant.repl.state/system)
                                            '{:find  [?link]
                                              :in    [x]
                                              :where [[?e2 :embed/content nil]
                                                      [?e2 :embed/id ?link]]})
returns everything


@U899JBRPF bumping this, not sure if you saw. quick repro:

(c/put node {:crux.db/id 1 :foo nil})
  (c/put node {:crux.db/id 2 :foo 2})
  @(c/q node '{:find  [?e]
               :where [[?e :foo nil]]})

;; #{[2] [1]}


thanks for the bump, indeed I missed it! The repro is very appreciated


@U797MAJ8M I'm opening an issue for this tomorrow, but essentially nil is being treated like _ in your query. As a workaround you can wrap the nil in a literal set #{nil] and it should work as you were expecting