On Wed, Mar 20, 2019 at 11:04 AM david scheck <schecksda...@gmail.com> wrote: > > Hi everyone, > > I'm trying to implement a nested JSONB index on a nested field in the json > file. I searched through internet and came at the conclusion that I had to > create it manually. > > so that's where I am. > > op.create_index('ix_law_search_vector', 'law', ['search_vector'], > unique=False, postgresql_using='gin') > > > first of all, I don't understand the 3rd argument. what does this represent? > the name of the index?
the first argument is the name of the index. All the remaining positional arguments are SQL expressions. So the ['search_vector'] is probably wrong. > > this is what should be. but my problem is that my desire index is very deep > in the JSONB. > > > that's what I've to target : > Image.image_metadata['afield']['anotherfield']['fieldindex'] > > > I want to create an index on fieldindex. > > > but if I do : > > op.create_index('uri', ['search_vector'], unique=False, > postgresql_using='gin') > > > as there is a lot of field 'uri' in the json, will it index all this fields > in 1 ? > > > (I'm new to sqlalchemy, I usually use the django orm, so sorry in advance). Right so in SQLAlchemy, you don't have to figure any of this out. Just get the Postgresql syntax you want exactly and run it, op.execute("CREATE INDEX whatever"). if you show me the syntax I can see how to make Index() do it too but to just emit a very specific CREATE INDEX, you can just type it out. > > > Thanks for answers > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.