Menu
  • HOME
  • TAGS

Creating index while updating the documents

mongodb,indexing

The amount of time it takes to add the index would depend on your hardware, but with 20206 records a simple index as you describe shouldn't take very long for most hardware. Queries fully covered by the index (i.e. where you specify A and B, or just A, but not...

Creating Index in Elasticsearch using Java API giving NoClassFoundException

java,indexing,elasticsearch

ES 1.5.2 uses Lucene 4.10.4. Get the jars you need from here. Note that you might need not only lucene-core but others as well. Just browse the Maven repo and look for other jars as well, but all should be version 4.10.4.

python and arduino : list index out of range err

python,indexing,arduino

Others have tried to answer the question - but I think the basic confusion is not resolved line[:-5] will remove last 5 characters from a line For example if your line is 'abcdefghijklm' then line[:-5] would give 'abcdefgh'. Now let's look at your adruino code specifically following line Serial.print(id_lum) Now...

Lucene get all non deleted document from index file

java,indexing,lucene

Lucene provides a bitset of all non-deleted documents, called liveDocs. You can get it by iterating over all LeafReaders (or using the SlowCompositeReaderWrapper) and calling the liveDocs method or by using the MultiFields class. Once you have this bitset, you can iterator from 0 to IndexReader#maxDoc and consult the bitset...

PL/SQL can't put value into index by table

table,indexing,plsql,insert,value

Your TYPE emp_table is table of employees%ROWTYPE INDEX BY PLS_INTEGER; only declares a type, not an actual variable you can write into. You need to add the variable too: TYPE emp_table_type is table of employees%ROWTYPE INDEX BY PLS_INTEGER; emp_table emp_table_type; Please note I added "_type" suffix into your definition....

indexing a text file into two arrays

c#,file-io,indexing

A simple approach using Linq var lines = File.ReadLines(@"d:\temp\test.txt"); List<string> apollo = lines.Take(6485).ToList(); List<string> sabre = lines.Skip(6485).Take(6485).ToList(); Of course I take for granted that your file has effectively the number of lines that you have specified....

Numpy: Multidimensional index. Row by row with no loop

python,numpy,multidimensional-array,indexing,vectorization

The complicated slicing operation could be done in a vectorized manner like so - shp = A.shape out = A.reshape(shp[0],shp[1],-1)[np.arange(shp[0]),:,B[:,0]*shp[3] + B[:,1]] You are using the first and second columns of B to index into the third and fourth dimensions of input 4D array, A. With it means is, basically...

What can I use as an array index in GLSL in WebGL ?

arrays,indexing,glsl,webgl

In WebGL/GLES2: Yes, only constants are allowed. However if your code can be unrolled (either by yourself or by the compiler) then it counts as a constant and you have a workaround. For example, The problem: uniform int i; ... int a[4]; a[2] = 42; // ✓ a constant index,...

IF duplicate cell value found in column then return value

excel,if-statement,indexing,match,countif

Here is a User Defined Function (aka UDF) to accomplish the task. Function my_Travels(nm As Range, loc As Range, cal As Range) Dim n As Long, cnt As Long, v As Long, vLOCs As Variant, vTMPs As Variant Dim iLOC As Long, sTMP As String my_Travels = vbNullString '"no travels"...

Referencing numpy array locations within if statements

python,arrays,matlab,numpy,indexing

Looks like index is an array of some sort, but when you do index(y) and index(x), Python thinks you're trying to call a function index() using x and y as parameters, respectively. If you're trying to simply access the elements, use index[x] and index[y]....

MySQL indexes performance on huge tables

mysql,sql,database,performance,indexing

For this query: SELECT MAX(YEAR(p.birthdate)) as max_year, wi.department as department FROM person p INNER JOIN works_in wi ON wi.person_id = p.id WHERE p.birthdate IS NOT NULL GROUP BY wi.department; The best indexes are: person(birthdate, id) and works_in(person_id, department). These are covering indexes for the query and save the extra cost...

Variable indexes outside of defined range in AMPL

variables,indexing,set,linear-programming,ampl

In AMPL, you can create or define your own "sets" for valid indices and use them in your constraints. So, in your case, to avoid invalid indices, you can define a set of permissible indices: param inner_i {2..(N-1)} and loop over those when creating the constraints. The price we pay...

MySQL performance with index clairification

mysql,performance,indexing

Indexes have their own "tables", and when the MySQL engine determines that the lookup references an indexed column, the lookup happens on this table. It isn't really a table per-se, but the gist checks out. That said, it will be nanoseconds slower, but not something you should concern yourself with....

How to get a mysql query to use a specific index?

mysql,database,table,indexing

If the index is appropriate it will be used without explicitly specifying it. Given you are using SELECT * I would not expect your index to be used (even if the INDEX hint had the correct syntax). The choice is down to the query optimiser's heuristics. The correct syntax is:...

Postgres does not use an index even less than 5% rows are returned

database,postgresql,indexing,database-performance

I guess you can't reply in comments so I have to post an answer. Explain analyze showed, that your timestamp columns are compared with numeric values timestamp >= 1431093600.00 and timestamp <= 1431100800.00 and because of that they were cast to numeric: Filter: ((numvalues[1] IS NOT NULL) AND (("timestamp")::numeric >=...

Why can't I access the elements of my NSMutableArray?

objective-c,indexing,nsmutablearray

You don't put integers, or NSIntegers, into the array, but objects, i.e. instances of NSNumber. NSNumber *number = patternA[3]; long a = number.longValue; will give give you correct value. This is called boxing / unboxing - putting plain values into objects. So what you were dumping was more or less...

IndexError obstructing code from working with larger csv file

python,csv,indexing,pandas

It is difficult without seeing the data causing the error, but try this: mode = (lambda ts: ts.value_counts(sort=True).index[0] if len(ts.value_counts(sort=True)) else None) ...

SQL - Avoid 2 columns in 1 record having the same value

mysql,indexing

Normally you would use a CHECK constraint for that. Bu MySQL does currently not support them. It accepts the input but ignores them. But you can use a trigger that cancels the insertion/update on certain conditions like this delimiter // CREATE TRIGGER check_trigger BEFORE INSERT ON your_table FOR EACH ROW...

Postgres tsearch performance on first query

performance,postgresql,indexing,full-text-search,ispell

It is known problem - loading ispell dictionary is slow (it is loaded every time when dictionary is used first time in session). One and good solution is session pooling. Other solution is using shared ispell dictionary - extension that was written by Tomas Vondra - shared_ispell, but I don't...

retrieve Hashmap Elements by index based

java,indexing,hashmap

First of all, you will have to use LinkedHashMap. Map pins = new LinkedHashMap(); and then after putting in the values, you can do the following: List keys = new ArrayList(pins.keySet()); List values = new ArrayList(pins.values()); System.out.print((String)keys.get(0) + " " + (String)values.get(0)); ...

php not executing in a get_file_contents document

php,indexing,footer,copyright

Is it possible to share the code which is in footer.php and confirm that how you are including the file

Unable to understand the error generated

python,indexing,range

What don't you understand exactly ? The error message is quite clear: you have an IndexError (you're trying to access a non-existant item in a list, tuple or other similar indexed sequence) at line 105, which is student_grade_system = StudentGradeSystem(sys.argv[1]) In this line there's only one indexed access - sys.argv[1]...

Decision to use KEY or UNIQUE KEY

mysql,indexing,unique-index

Both unique and non-unique indexes result in I/O operations for INSERT, DELETE, and UPDATE statements. The amount of index overhead should be pretty much the same. The difference is that unique indexes might result in a failure of an INSERT or UPDATE under normal use (of course, the operations might...

Finding a specific cell contanining value greater than the desired value

excel,indexing,excel-formula,vlookup

With 125 typed into D2 the first will return 101 from Range A; the second will return 500 from Range B. =INDEX(A:A, MATCH(D2, A:A)) =INDEX(B:B, MATCH(D2, A:A)) This method is known as a INDEX/MATCH function pair.        When seeking approximate matches, the values to be examined must be in ascending...

Neo4j: configure legacy index with cypher or property file

indexing,neo4j

I've written some code that might be helpful: neo4j-fti It basically hooks into the startup process and creates manual indexes with customizable analyzers. ...

Checking whether indexes are being used in SQL query?

mysql,sql,indexing,phpmyadmin

No, it's using an index. The ref and keylen tell us that. I think you may be confused by the Using index in the Extra column of the other rows in the EXPLAIN output. That means that the query is being satisfied entirely from the index, without a need to...

Subsetting and Indexing in For Loop in R

r,for-loop,indexing,minimum

If you wanted to get the n smallest values in a dataset sorted by rank, you can do this with the order and head functions -- no need for the for loop: num <- 10 head(df[order(df$Rank),], num) # State City Value Rank # 7 State1 city7 0.1075155728 1 # 19...

How to use all the cores of Solr in solrj

java,indexing,solr,lucene,solrj

here in your code it still points to core1. HttpSolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr/core1" In case you want to have the indexex for core2 you need to change here HttpSolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr/core2" after this change try run the job, it will index for the core2....

Fast indexing using multiple ES nodes?

java,indexing,elasticsearch,lucene,scalability

Answer1: No. The speed of indexing will in fact decrease if you enable replication (though it may increase search performance). You can look at this question for improving indexing performance. Answer2: It depends (if no replica then same). During indexing the data will go only to data nodes. Your cluster...

Postgres Index-only-scan: can we ignore the visibility map or avoid heap fetches?

postgresql,indexing

There is no way to do what you want in PostgreSQL as it stands. It'd be interesting to do but a fair bit of work, very unlikely to be accepted into core, extremely hard to do with an extension, and likely to have worse side-effects than you probably expect. You'd...

np.argmax on multidimensional arrays, keeping some indexes fixed

numpy,multidimensional-array,indexing,argmax

This here works for me where Mat is the big matrix. # flatten the 3 and 4 dimensions of Mat and obtain the 1d index for the maximum # for each p1 and p2 index1d = np.argmax(Mat.reshape(Mat.shape[0],Mat.shape[1],-1),axis=2) # compute the indices of the 3 and 4 dimensionality for all p1...

C# implementation of Dictionary to Create an index of words

c#,visual-studio,dictionary,indexing,text-processing

Try something like this: void Main() { var txt = "that i have not had not that place" .Split(" ".ToCharArray(),StringSplitOptions.RemoveEmptyEntries) .ToList(); var dict = new OrderedDictionary(); var output = new List<int>(); foreach (var element in txt.Select ((word,index) => new{word,index})) { if (dict.Contains(element.word)) { var count = (int)dict[element.word]; dict[element.word] = ++count;...

Postgres 9.4 jsonb array as table

sql,json,postgresql,indexing,jsonb

Query Your table definition is missing. Assuming: CREATE TABLE configuration ( config_id serial PRIMARY KEY , config jsonb NOT NULL ); To find the a value and its row for given oid and instance: SELECT c.config_id, d->>'value' AS value FROM configuration c , jsonb_array_elements(config->'data') d -- default col name is...

Remove inf from Theano array

python,indexing,theano

I found an awkward workaround import theano import theano.tensor as T import numpy as np vec = T.vector() compare = T.isinf(vec) out = vec[(1-compare).nonzero()] v = [ 1., 1., 1., 1., np.inf, 3., 4., 5., 6., np.inf] v = np.asarray(v) out.eval({var:v}) array([ 1., 1., 1., 1., 3., 4., 5., 6.])...

Jquery/javascript named index array with array association

javascript,jquery,arrays,indexing,named

I want to know if its possible... Yes, although the way you're using it, you wouldn't want an array, you'd just want an object ({}) (see below). ...(and correct)... Some would argue that using an array and then adding non-index properties to it is not correct. There's nothing technically...

Lucene how to index in Database (Cassandra)

java,indexing,lucene,cassandra

It will not look like a relational database table, instead Lucene uses the inverted index and cosine similarity formula for searching of any search words. To better understand you need to look for various terminology and formula to be used in lucene, you can check out it on lucene officially...

SQL Index - is this overlapping?

sql,sql-server,indexing

No, it would not be safe to remove that. The order and position of the columns is important. The introduction of the price column between the other two columns (brand and model) is the issue. Without the index on just (brand,model), the the model values are "in order" under the...

Oracle Function Based Index: Modify a deterministic function?

oracle,indexing,plsql,deterministic

Yes, you have to rebuild the index. Check this link on Oracle Docs, section Disadvantages of Function-Based Indexes. An index does store physical data, be it function-based or otherwise. If you modify the underlying deterministic function, your index no longer contains the valid data and you have to rebuild it...

Delete ndb EntitiesByProperty index table

google-app-engine,indexing,gae-datastore,app-engine-ndb

Yes, you'll have to re-put all of your entities in order to update the values in the indexes (or remove them, as you're asking)

Trying to create a new dataframe based on internal sums of a column from another dataframe using Python/pandas

python,indexing,pandas,sum,dataframes

Here is one way to avoid loop. import pandas as pd your_df = pd.DataFrame({'Col1':[1,2,3,4], 'Col2':[5,6,7,8]}) def your_func(df, column, cutoff): # do cumsum and flip over x = df[column][::-1].cumsum()[::-1] df[column][df.index > cutoff] = x[x.index > cutoff] return df # to use it your_func(your_df, column='Col1', cutoff=1) Out[68]: Col1 Col2 0 1 5...

Converting MATLAB to Python: too many indices return error

python,arrays,matlab,numpy,indexing

It looks like index is a 1-d array? (you have index[y] and index[x] on line 5 and 8, and say it is of length 16) But, on line 11, you are trying to access its second dimension: index[y,:]. Maybe that should be indexdn[y,:] =-indexdn[:,y]?...

Why does my array lose its mask after doing multidimensional indexing in Numpy?

python,numpy,multidimensional-array,indexing

Looks like indexing with a masked array just ignores the mask. Without digging much into the docs or code, I'd say the numpy array indexing has no special knowledge of the masked array subclass. The array you get is just the normal arange(20) indexing. But you could perform normal indexing,...

Python: How to index the elements of a numpy array?

python,arrays,numpy,indexing

Given that your desired output is a dictionary, I don't think there's going to be an efficient way to do this with NumPy operations. Your best bet will probably be something like import collections import itertools d = collections.defaultdict(list) for indices in itertools.product(*map(range, a.shape)): d[a[indices]].append(indices) ...

Which tables do not have indexes in Oracle? [closed]

oracle,indexing,sqlplus

Well, normally I wouldn't do this, but here you go: SELECT t.TABLE_NAME FROM USER_TABLES t LEFT OUTER JOIN (SELECT DISTINCT TABLE_NAME FROM USER_INDEXES) i ON i.TABLE_NAME = t.TABLE_NAME WHERE i.TABLE_NAME IS NULL; Perhaps your question should be "Why did someone just do my homework for me?". Best of luck....

Covering index and getting rid of Key Lookup

sql-server,indexing,key

The problem is that your index can't really be used for the join. To be usable, the first field(s) in the index must be such that you're also joining the table with (or exist in the where clause). INNER JOIN exception AS ex ON ed.exceptionDefId = ex.exceptionDefId AND ex.loanId IS...

Find the sentence’s index (sentences in a list) of a specific word in Python

python,list,indexing,nltk

You can iterate over each string in the list, split on white space, then see if your search word is in that list of words. If you do this in a list comprehension, you can return a list of indices to the strings that satisfied this requirement. def f(l, s):...

Is there a way to associate data with a file in a folder hierarchy?

java,indexing,uniqueidentifier,tagging,subfolder

If you want to keep track of a file, even when its name and/or location changes, you should use its unique identifier, which in most file systems is called its inode. (I think NTFS/Windows calls it a "file ID.") You can read a file's inode using its BasicFileAttributes.fileKey: Object key...

Printing corresponding elements from multiple lists by using known element from a single list in Python

arrays,indexing,elements

Looks like you can use the numpy where function: //Set i to be index of h in data i = numpy.where(data==h) ...

Python Pandas: select rows based on comparison across rows

python,indexing,pandas

Try this. import pandas as pd import numpy as np index = 'A A A B B C D D'.split() col1 = [120, 90, 80, 80, 50, 120, 150, 150] ser = pd.Series(col1, index=index) # use groupby and keep the first element ser.groupby(level=0).first() Out[200]: A 120 B 80 C 120...

How to force use of indices in MongoDB?

mongodb,indexing

The notablescan ( http://docs.mongodb.org/manual/reference/parameters/#param.notablescan ) option for the MongoDB binary (mongod.exe or mongod depending on your OS) allows you to stop any query, with an emitted log error, which does not use an index at all. This option will not stop inefficient queries though so that part will still need...

Indexing cannot yield multiple results in MATLAB

matlab,indexing,confusion-matrix

This error tells me that you've defined a variable max somewhere in your code. Indexing cannot yield multiple results Why? Because otherwise [Max, argmax1]= max(simoutelem); wouldn't be taken as a case of "Indexing". Easy proof at command line: [a b] = max([1 2 3 4 5]) % works max =...

Do you get the same performance using index prefixes?

performance,mongodb,indexing

A "compound index" which is the correct term for your "link" does not create any performance problems on "read" ( since writing new entries is obviously more information ) than an index just on the single field used in the query. With one exception. If you use a "multi-Key" index...

Python `dict` indexed by tuple: Getting a slice of the pie

python,dictionary,indexing,tuples

The way your data is currently organized doesn't allow efficient lookup - essentially you have to scan all the keys. Dictionaries are hash tables behind the scenes, and the only way to access a value is to get the hash of the key - and for that, you need the...

How can I use MySQL statement 'show index' with PDO?

php,mysql,indexing,pdo,show

are you sure it fails? what is the result of this code? $pdo = new PDO( "mysql:dbname=" . SQL_DB . ";host=" . SQL_HOST, SQL_USER, SQL_PWD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); try { $stm = $pdo->prepare("show index from `TABLENAME` where `Key_name` = 'PRIMARY'"); $res = $stm->execute(); print_r($stm->fetch(PDO::FETCH_ASSOC)); } catch (Exception...

Get specific values form JSON Table with javascript over IDs

javascript,arrays,json,indexing

You are almost correct. Restructure your array into an associative array of associative arrays. You can call them by array_name['first_index']['second_index']. var testext = { "key1": { "firstName": "Ray", "lastName": "Villalobos", "joined": 2012 }, "key2": { "firstName": "John", "lastName": "Jones", "joined": 2010 } }; document.getElementById("demo").innerHTML = testext['key1']['firstName']; <div id="demo">Default</div> ...

Looping through numbers to create a large table

excel,vba,excel-vba,indexing

For this first code block, I tried to stay with the general structure of the code in your question. I could have for example swapped out the innermost two For loops for a single While loop. That would be more efficient but requires a significant logic change. I did make...

Do index names have to be unique across entire database in Mysql?

mysql,sql,indexing

Yes you can use same index name for both the tables. CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX IDnum [index_type] ON tbl_name (index_col_name,...) [index_type]...

What indexer do I use to find the list in the collection that is most similar to my list?

search,indexing,solr,levenshtein-distance

I wonder what keeps you from trying it with Solr, as Solr provides much of what you need. You can declare the field as type="string" multiValued="true and save each list item as a value. Then, when querying, you specify each of the items in the list to look for as...

Manipulate a matrix based on another matrix

matlab,indexing

Here a solution using a For loop statement. Let me know if this correspond to what you are looking to do: idxList = []; for ii = 1:size(est,1) if k(ii,1) == 0 idxList = [idxList ii]; end end est(idxList) = []; The code makes a list of index for all...

mysql multiple indexes for small sets of values

mysql,indexing

In this particular case when you have searches based on user_id channel and type you can use covering index (composite) which would be efficient. If the table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to look up rows. http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html So you...

Python numpy bool masks for absoluting values

python,arrays,numpy,indexing,masking

Firstly, you could instantiate your array directly using np.random.randint: # Note: the lower limit is inclusive while the upper limit is exclusive x = np.random.randint(-5, 6, size=(5, 5)) To actually get the job done, perhaps type-cast to bool, type-cast back, and then negate? res = 1 - x.astype(bool).astype(int) Alternatively, you...

Searching a TextField and IntField together seperated by an AND condition In Lucene

java,search,indexing,lucene

There are a few possibilities. First, what I would most recommend in this case, is perhaps you don't need those IntFields at all. Zip codes and IDs are usually not treated as numbers. They are identifiers that happen to be comprised of digits. If your zip code is 23456, that...

Optimizer using an index not present in the current schema

oracle,indexing,optimizer

You're connected as user ALLL, but you're querying a table in the HR schema: SELECT /*+ FIRST_ROWS(25) */ employee_id, department_id FROM hr.employees WHERE department_id > 50; You stressed other schema in the question, but seem to have overlooked that the table you're querying is also in another schema. The employees...

comparing index values in an array

ruby-on-rails,ruby,indexing,each

I think I understand what you're trying to achieve: You want to make sure that a player has a ranking between the minimum and maximum ranking, but you only store the ranking in each model as a string. The ranking array has rankings in ascending order, but I'm not sure...

How to count the characters of each line in a string and convert the number to a hex

java,arrays,indexing,hex

String msg = "Bruce Wayne,Batman,None,Gotham City,Robin,The Joker\n" + "Oliver Queen,Green Arrow,None,Star City,Speedy,Deathstroke\n" + "Clark Kent,Superman,Flight,Metropolis,None,Lex Luthor\n" + "Bart Allen,The Flash,Speed,Central City,Kid Flash,Professor Zoom"; String[] lines = msg.split("\n"); for(Integer i = 1; i <= lines.length; i++){ int numChars = 0; String[] toks = lines[i - 1].split(","); for(String tok : toks){ numChars...

Apache Cassandra. Specific case for an Index or a table with composite primary key

indexing,cassandra,cassandra-2.0,composite-primary-key

Try avoiding secondary indexes to the maximum extent If the only query is to retrieve all B-IUD for a particular A-IUD, have a composite primary key (A-IUD, B-IUD). If you also need to search for a particular B-IUD, have two tables 1 : Table 1 : with B-IUD as the...

Creating NxM indices from a Python array

python,numpy,indexing

From your comment: x = np.arange(25).reshape((5,5)) A = [[node0,node1,...node24], [column index for each node above from 0 to 24], [row index for each node from 0 to 24], [value for each node from 0 to 24]] One easy way to collect this sort of information would be loop like A...

Pandas: break categorical column to multiple columns

python,indexing,pandas

You could use set_index to move the type and id columns into the index, and then unstack to move the type index level into the column index. You don't have to worry about the v values -- where the indexes go dictate the arrangement of the values. The result is...

Numpy Indexing: Get every second coloumn for each even row

python,numpy,indexing

Okay if we can not avoid any copy, than the easiest thing to do would be probably something like: a = np.arange(16).reshape(4,4) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) b = np.zeros((a.shape[0], a.shape[1]/2)) b[::2,:] = a[::2,1::2] b[1::2,:] =...

Postgres full text search: how to search multiple words in multiple fields?

sql,postgresql,search,indexing,full-text-search

It looks like what you want is, in fact to search the concatenation of all those fields. You could build a query doing exactly this ... where to_tsvector('italian', name||' '||coalesce(decription,'')...) @@ to_tsquery('$word') and build an index on the exact same computation: create index your_index on shop using GIN(to_tsvector('italian',name||' '||coalesce(decription,'')...)) Don't...

PHP Autoincrement Array

php,arrays,indexing,key,key-value

You may consider using for() and array_push() function. Schematic code could look like this: $paymentsArray = array(); $day = "27"; $month = "05"; $year ="2015"; for($i=0; $i <= $PaymentCounts; $i++) { array_push($paymentsArray, array('Amount1' => "100.00", 'AmountDate1' => "$day.$month.$year")); $month++; } $arr = array ('Client' => "Alex", 'BillNumber' => "123", 'PaymentCounts'...

Python: How to check the value of a non-existent list element without getting IndexError?

python,list,if-statement,indexing,indexoutofboundsexception

Just test if there are enough elements: x = 'foo' if len(myList) > 2 and myList[2] is not None else 'bar' It doesn't matter if the first 2 elements are missing or if you have more than 3 elements. What matters is that the list is long enough to have...

Multiple field Indexing in pymongo

mongodb,indexing,pymongo

>>> from pymongo import IndexModel, ASCENDING, DESCENDING >>> index1 = IndexModel([("hello", DESCENDING), ... ("world", ASCENDING)], name="hello_world") This was mentioned in the doc for pymongo db[collection_name].ensure_index([("field_name1" , TEXT),("field_name2", TEXT)],name="index_name")) This will provide a composite index on [field_name1,field_name2] http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_indexes...

How can I access semi-sparse data efficiently in java?

java,arrays,indexing

From what you've described here you can use HashMap<Integer, Node> or HashMap<Long, Node> depending on the range of ids you have. Depending on your other requirements LinkedHashMap and TreeMap might be alternatives (LinkedHashMap if you need to iterate over the nodes in the order that they were inserted and TreeMap...

Getting index of a certain element in a 2D numpy array

python,numpy,multidimensional-array,indexing,dynamic-arrays

To get the row with the highest number of non-zero cells and the highest sum you can do densities = x.sum(axis=1) lengths = (x > 0).sum(axis=1) center = x[(densities == densities.max()) & (lengths == lengths.max()] Try to avoid using loops in numpy. Let me know if this isn't what you...

Optimize the execution of select

sql-server,indexing,query-optimization,clustered-index,non-clustered-index

There's few things to consider when creating indexes, for example in this case: How many rows have Dane5 > 199850 and how many rows there are in total? Are there a lot of updates to the columns in the index -> slowness to updates. Are there going to be a...

Multidimensional List get Position of a String Python

python,string,list,indexing,set

You can create a dictionary and then return the set() of the value for a given key. Example >>> def returnSetOfList(scheme, key): ... a_dict = dict(scheme) ... return set( a_dict[key] ) ... >>> relational_scheme = [["F",["DC"]],["A",["EBD"]],["DC" , ["BAF"]],["E",["DB"]]] >>> returnSetOfList(relational_scheme, "F") set(['DC']) ...

Create a text index on MongoDB schema which references another schema

javascript,node.js,mongodb,indexing,mongoose

I think, what you are looking for is the ability to join tables of data and perform a query against the sum of that data. That is something you need a relational database for, which MongoDB isn't. So I recommend you change your approach in how you would like to...

python compare items in 2 list of different length - order is important

python,list,loops,for-loop,indexing

Use the zip() function to pair up the lists, counting all the differences, then add the difference in length. zip() will only iterate over the items that can be paired up, but there is little point in iterating over the remainder; you know those are all to be counted as...

replace zero values with previous non-zero values

matlab,indexing,vectorization

Try this, not sure about speed though. Got to run so explanation will have to come later if you need it: interp1(1:nnz(A), A(A ~= 0), cumsum(A ~= 0), 'NearestNeighbor') ...

Problems with matrix indexing using for loop and if condition

matlab,if-statement,for-loop,matrix,indexing

You can use bsxfun to avoid for-loop (note that it is actually not vertorizing): value1 = bsxfun(@times,data(params(:,11),:),(params(:,8)==1)); value2 = bsxfun(@times,data(params(:,11),:),(params(:,8)==2)); value3 = bsxfun(@times,data(params(:,11),:),(params(:,8)==3)); But it still gives you the results with zero rows. So you can remove zero-rows by: value1(all(value1==0,2),:)=[]; value2(all(value2==0,2),:)=[]; value3(all(value3==0,2),:)=[]; You can also use above commands to remove...

Does PostgreSQL quickly search for columns with arrays of strings?

arrays,database,performance,postgresql,indexing

GIN and GiST indexes are generally bigger than a simple b-tree, and take longer to scan. GIN is faster than GiST at the cost of very expensive updates. If you store your tags in an array column then any update to the row will generally require an update to the...

Retrieve index of newly added row - for loop in R

r,for-loop,indexing

This isn't very elegant, but it might work better than using two functions to fill in the rows and columns separately. Here, x is a list of all your matrices; factor is an optional list of desired row and column names fix_rc <- function(x, factors) { f <- function(x) factor(ul...

Search for nodes in Neo4j with schema index

indexing,neo4j,lucene

As of today schema indexes just support exact matches, e.g. MATCH (p:Person) WHERE p.name='abc' or IN operators MATCH (p:Person) WHERE p.name in ['abc','def'] Future releases might have support for wildcards as well....

R - How to re-order row index number

r,vector,indexing,data.frame,row

You can use row.names(yourdf) <- NULL to reset the row names...

Creating SQL Indexes?

mysql,sql,indexing,phpmyadmin

I think you need a composite index that includes both the ID that you're using in the JOIN and the timestamp. Otherwise, it will just use the ID indexes for the join, but it will then have to scan all the matching rows to do the timestamp comparisons. CREATE INDEX...

How do I create a dictionary that indexes the location of certain keys?

python,dictionary,indexing,data-structures

From what I understand, you want a dictionary that is capable of returning the keys of dictionaries within dictionaries if the value the key's are associated with match a certain condition. class SubclassedDictionary(dict): def __init__(self, new_dict, condition=None, *args, **kwargs): super(SubclassedDictionary, self).__init__(new_dict, *args, **kwargs) self.paths = [] self.get_paths(condition) def _get_paths_recursive(self, condition,...

MySQL not using index when where condition have if clause

mysql,indexing

In general, databases (including MySQL) do not use indexes when columns are the arguments to functions. You could try: SELECT * FROM mytable WHERE (@type = 1 and col1 = 1420070400) or (@type <> 1 and col2 = 1420070400); But, it is unlikely that this will use an index either....

Lucene vs Solr, indexning speed for sampe data

java,indexing,solr,lucene,full-text-search

Solr is a general-purpose highly-configurable search server. The Lucene code in Solr is tuned for general use, not specific use cases. Some tuning is possible in the configuration and the request syntax. Well-tuned Lucene code written for a specific use-case will always outperform Solr. The disadvantage is that you must...

Creating analyzed and not_analyzed index on all fields in Elasticsearch

python,indexing,elasticsearch,mapping

You can go through the document here. Using dynamic index templates , you can add rules like below and achienve the same. In the following example , I have enabled an additional field called raw ONLY if the size is less than 256 which would be not_analyzed. { "mappings": {...

Why MongoDB doesn't uses Index Intersection?

mongodb,indexing,database-indexes,mongodb-indexes

There are some details about the index selection in the SERVER-3071 JIRA issue but I cannot say if all is still relevant for 3.0. Anyway: MongoDB 3.0.2 seems not consider index interaction for range query. But it will for point intervals: > db.orders.find( { item: {$eq : "abc123"}, qty: {...