Monday, July 28, 2014

Steps to install the smlar extension into Postgres

The smlar extension lets you do TF-IDF and cosine similarity calculations in Postgres.

If you figure out how to compile these on Windows (64-bit), please let me know.

In your shell:

cd /usr/local/src

git clone git://sigaev.ru/smlar.git

cd smlar

export USE_PGXS=1

make

make install


In Postgres:

create extension smlar;

Test it out:

select smlar( '{a,b}'::text[], '{c,a}'::text[] );

Output
smlar
real
10.5

4 comments:

jowdjbrown said...

If you figure out how to compile these on Windows (64-bit), please let me know.chrome extension tutorial

Karl G said...

I'm unable to compile on Centos, the error below, any ideas?

$ sudo make install
Makefile:23: ../../src/Makefile.global: No such file or directory
Makefile:24: /contrib/contrib-global.mk: No such file or directory
make: *** No rule to make target `/contrib/contrib-global.mk'. Stop.

Brian said...

Karl, you can comment out all the lines in the makefile, starting from line 15, in this pattern.

#ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
#else
#subdir = contrib/smlar
#top_builddir = ../..
#include $(top_builddir)/src/Makefile.global
#include $(top_srcdir)/contrib/contrib-global.mk
#endif


The reason for this is that when using an older version of postgresql, you need to compile with extension building support. I suspect that this is only useful for older versions of postgresl. If you don't care about this, then you'll be ok leaving it out.

lionstep said...

Do you know how do you compile it without pgxs? I don't have a "Makefile.global" or a "contrib-global.mk"