Questions tagged [indexing]

11389 questions
0

votes
4

answer
34

Views

How to get the maximum value in a matrix and its row number

I would like to get the maxim value of a matrix and just its row position in the matrix. How to do that? Thanks again. I can get the maximum value in the matrix with the following code; but, I am not sure how to get its row index position. To be noticed that the matrix could also has equal values f...
chrisis
1

votes
1

answer
57

Views

How to index nested array

How to index (N1QL query in Couchbase) above document to speed up searching by SerialNumber field in nested array (doc => groups => items => item.SerialNumber)? Sample: { 'Id': '0012ed6e-41af-4e45-b53f-bac3b2eb0b82', 'Machine': 'Machine2', 'Groups': [ { 'Id': '0fed9b14-fa38-e511-893a-0011256...
Michał Zych
1

votes
1

answer
1.3k

Views

access golang struct field with variable

For reference: example here I am trying to access a struct field using a variable key, to explain in PHP you can do the below. $arr = ['test' => 'foo']; $key = 'test'; $result = $arr[$key]; Or in Javascript you can do the below const obj = {'test': 'foo'} const key = 'test' const result = obj[key] I...
Sam White
1

votes
3

answer
123

Views

Slicing a pattern in a large 1-d NumPy array

I have got a 1-d array where I have a pattern in the enteries. I will give an example. In the array arr, I have first 4 enteries with single digits, next 4 enteries with two digits and then the next 6 enteries with 3 digits. (This single, double, triple digit thing is just to highlight the pattern...
Sheldore
-1

votes
1

answer
16

Views

Why does indexing into a list with list[n] instead of list[[n]] in R not do what you would expect?

In an R list, why does indexing with [n] instead of [[n]] not return the nth element as non-R-programmers would expect? lfile
smci
0

votes
1

answer
19

Views

why the swapping does not take place when indices are 0 and 1?

I have an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. It is allowed to swap any two elements. I need to find the minimum number of swaps required to sort the array in ascending order. Starting from the first element of the list, I try to put them in...
Golluu
0

votes
1

answer
14

Views

How to compute an index in r?

It is my first time I am asking a question in this great community. I am trying to calculate an index on a data.frame, show them by borough or neighborhood and plot. Which code suited the most? Here is an example of a data set I have. albo, aegy = mosquito species, house = house prospected, The hous...
Armel Tedjou
1

votes
2

answer
288

Views

Numpy: Combine list of arrays by another array (np.choose alternative)

I have a list of numpy arrays, each of the same shape. Let's say: a = [np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), np.array([[11, 12, 13], [14, 15, 16], [17, 18, 19]]), np.array([[99, 98, 97], [96, 95, 94], [93, 92, 91]])] And I have another array of the same shape that gives the list indices I wan...
Max16hr
1

votes
2

answer
10

Views

capitalize next non-empty element in next list of nested lists

My function aims to take a string as input then output the same string printed the number of times equal to the count of non-empty characters in the string, with the next non-empty element in the next list capitalized. The final output should contain the new strings in a list. Example: Input: hell...
Mr. Jibz
1

votes
1

answer
19

Views

Enforcing index scan for multicolumn comparison

I know that index internally is B-tree or similar tree structure. Suppose index is built for 3 columns (a,b,c), I want Postgres to: find key [a=10, b=20, c=30] in that B-tree, scan next 10 entries and return them. If the index has only one column the solution is obvious: select * from table1 where...
Yuri Yaryshev
1

votes
2

answer
781

Views

SQL Overlapping and Multi-Column Indexes

I am attempting to tune some stored procedures and have a question on indexes. I have used the tuning advisor and they recommended two indexes, both for the same table. The issue is one index is for one column and the other is for multiple columns, of which it includes the same column from the first...
Dustin Laine
1

votes
1

answer
794

Views

Elasticsearch: add a synonym filter on my english analyser

I've got an index with a field description which is analysed like that: 'description':{ 'analyzer' : 'english', 'type' : 'string' } I have defined an synonyms dictionnary in a file synonyms.txt which contain: ipod, i-pod, i pod => i-pod I would like to add this synonym dictionnary to my analyzer, bu...
mel
1

votes
1

answer
830

Views

MongoDB Internal implementation of indexing ?

I Learn Lot of things About indexing and find some stuff from Hereenter link description here Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the qu...
nitesh singh
1

votes
4

answer
58

Views

Get index of elements in first Series within the second series

I want to get the index of all values in the smaller series for the larger series. The answer is in the code snippet below stored in the ans variable. import pandas as pd smaller = pd.Series(['a','g','b','k']) larger = pd.Series(['a','b','c','d','e','f','g','h','i','j','k','l','m']) # ans to be gene...
par
1

votes
1

answer
54

Views

Angular/Typescript Map using last index on every object

I'm trying to create an array of 120 objects (hex's for a map) and then add info to each one. When I use map the id is supposed to be the index of the current object and I can console log the correct, current index as expected but for some reason EVERY object has an id of 119. I've looked at some of...
gv0000
1

votes
1

answer
30

Views

function that replaces the negative numbers of an array with 77

function Z=replacez(A) [M,N]=size(A); for i=1:M for j=1:N if A(i,j)
philip
1

votes
3

answer
55

Views

go one step back and one step forward in a loop with python

I need to loop in a list containing french words and find an asterisk because I want to concatenate the word before the asterisk and the word after the asterisk each time an asterisk appear and continue to the next. For example, in the sequence: ['les','engage', '*', 'ment', 'de','la'] I want to c...
Natália Resende
1

votes
5

answer
61

Views

How can I index a single value from a list containing sublists in python?

As an example, right now I have a list of: list = [[1276, 'c'], [910, 'b'], [819, 'o'], [759, 'z'], [699, 'l']] and I would like to index this list for only a specific letter, for instance: index = list.index('c') As is, I realize that I'm going to get a ValueError, and I've learned that to make thi...
Garrett B
0

votes
2

answer
22

Views

Optimize speed of Mysql JOIN query

I have 2 tables called T1 made of 1.6mln of rows and T2 made of 4.6mln of rows with with one-to-many relationship. The CREATE STMT of T1 is: CREATE TABLE `T1` ( `field_1` text, `field_2` text, `field_3` decimal(10,6) DEFAULT NULL, `field_4` decimal(10,6) DEFAULT NULL, `field_4` decimal(10,6) DEFAULT...
UgoL
1

votes
2

answer
69

Views

SOLVED: How to create UDF for multi-variable Index Match formula

I want to create a UDF for the following Excel index-match formula: {=INDEX($A$1:$J$7,MATCH(B9,$A$1:$A$7,0),MATCH(1,($A$1:$J$1=B10)*($A$2:$J$2=B11),0))} enter image description here AA AA AA BB BB BB CC CC CC a b c a b c a b c 1 10 55 24 48 95 19 5 28 65 2 16 48...
SteveC
1

votes
0

answer
114

Views

PostgreSQL: Index is used - but not when querying with LIMIT OFFSET

Let's say I have a messages table in a PostgreSQL database that contains many entries. The primary key of the table is just a simple serial column (like int but with 'auto increment'). Then I want to select the TOP-25 messages that a user received and that meet certain criteria. The result is ordere...
MrSnrub
1

votes
3

answer
78

Views

Why MongoDB is fetching documents from disk after a sort even when the used index contains all fields on the query

Apparently MongoDB is fetching all documents from disk to be able to fulfill a query after a sort. To illustrate the issue we can insert the following documents with a progress and a date into a foo collection: db.foo.insert({ '_id' : 1, 'progress' : 'A', 'date' : ISODate('2017-12-01T07:52:40.831Z')...
1

votes
1

answer
1.5k

Views

ErrorException thrown with message "htmlspecialchars() expects parameter 1 to be string, object given Stacktrace: #59

ErrorException thrown with message 'htmlspecialchars() expects parameter 1 to be string, object given (View: G:\xampp\htdocs\Blog\resources\views\songs\index.blade.php)' Stacktrace: #59 ErrorException in G:\xampp\htdocs\Blog\vendor\laravel\framework\src\Illuminate\Support\helpers.php:577 #58 ErrorEx...
Istiyak Amin
1

votes
1

answer
33

Views

INDEX formula for criteria with multiple outputs

This is the formula I am using, however, it is outputting the incorrect account. It seemed to be working when I tested it on a single sheet but when I changed the output and input sheet it stopped out putting the correct accounts. =IF(ISERROR(INDEX(Sheet1!$B$1:$C$1000,SMALL(IF(Sheet1!$B$1:$B$1000=A...
Condar87
1

votes
0

answer
292

Views

Very slow MongoDB queries while using IXSCAN as a winning plan for queries

I have DB with about 30M records in a collection with about 100GB collection size (total documents and indexes). I have a compound index that filters data based on user_id and some other fields like: is_active, is_logged_in, etc. With MongoDB Compass I see slow queries of about 10s, 20s or even 40 s...
ALH
1

votes
0

answer
31

Views

Index keywords in a pdf using regex

I have a pdf containing multiple instances of different authors in the following format: last name, first name, city, (country code) I would like to index them (using a regex) so you will get something like: Doe, John, New York City, (USA) - page: 1,3,5,6 What I tried to do was using JavaScript in A...
Code and coffee
1

votes
1

answer
35

Views

MySQL How to Optimize Sub Query Performance

I just created a table with: CREATE TABLE `table_test` ( `time` date NOT NULL, `line_id` char(36) NOT NULL, `location_id` char(36) NOT NULL, `placement_id` char(36) NOT NULL, `flight_id` char(36) NOT NULL, `impressions` int(11) DEFAULT `0`, PRIMARY KEY (`time`,`line_id`,`location_id`,`placement_id...
Thanh Thai Nguyen
1

votes
0

answer
81

Views

How to determine which columns to index in a SQL query

I have a program written in VB.NET with a SQL Server database, to manage my electric engines' system, where I have about 15000 records in my database till now and as I'm filling data more and more, my queries started to slow down exponentially. I decided to solve that issue by indexing, however I do...
Mohammad Fneish
1

votes
2

answer
77

Views

Index folders and files in python3

I wanted to create an index of all the files and folders that i have in an enterprise cloud so i could then do the backup of it and store the index into a txt file and after i will compare the two last backups ( the txt files ) to check which files/folders changed names. I have tried this code, but...
Daniel Santos
1

votes
0

answer
83

Views

Generate _id in R before saving data in mongoDB

I want to generate the mongoDB's _id from R side before saving data in mongoDB. I'm using package mongolite but there isn't this feature, are there others ways to achieve this goal?
Terru_theTerror
1

votes
0

answer
41

Views

Mongodb query for all values in in an indexed column doesn't use the index

I have a collection where I often want to pull the value of a field for all documents in the collection. Specifically, I want to get the 'filename' field for all documents. I have an index on this field: { 'v' : 2, 'key' : { 'filename' : 1.0 }, 'name' : 'filename_1', 'ns' : 'testdata.metadata' } How...
Mike Scannell
1

votes
1

answer
62

Views

Append pandas dataframe with column of averaged values from string matches in another dataframe

Right now I have two dataframes (let's call them A and B) built from Excel imports. Both have different dimensions as well as some empty/NaN cells. Let's say A is data for individual model numbers and B is a set of order information. For every row (unique item) in A, I want to search B for the (poss...
Sean Kelso
1

votes
2

answer
41

Views

Summing lists using *args and a specified list index

I previously posted a question on Stack Overflow asking how to combine lists made of integer values, while also summing the values at the respective indexes (Summing lists of different lengths in Python beginning at a specified index using a function). I got a good answer from @pault, but now I am w...
W. Churchill
1

votes
0

answer
59

Views

What is the best way to index several foreign keys?

Learning Oracle basics, I learned that foreign keys should be indexed, thanks to this question. However if I have a table with several foreign keys, should I create 1 index for each foreign key or 1 index for the entire table ? For example, I have the table A(a,b,c,d), b and c being foreign keys on...
TartineThomas
1

votes
1

answer
103

Views

Indexing Faces with AWS Rekognition

I am new to AWS and am trying to use Rekognition to identify certain people in a crowd. I am currently trying to index the images of the separate individuals but have hit a snag when trying to create a collection. There seems to a data type compatibility issue when I try using Amazon.Rekognition.Mod...
willed42
1

votes
0

answer
78

Views

Apply sortDescriptor to NSFetchRequest after grouping

I am building a Showroom that has 45000+ catalogs each represented as Literature in CoreData. To optimise search - instead of searching over Literature, I've added another entity - LiteratureSearchIndex in CoreData, that has searchvalue (either title word/keyword/tag etc. that represents part of the...
Valentin
1

votes
0

answer
26

Views

Document-level content of a full-text index of Persian Language

I want to extract words in a full indexed column in the Persian Language. I used sys.dm_fts_index_keywords_by_document to get them. It works, But the extracted words are in Arabic Alphabet, for example, 'عربسةان' instead of 'عربستان'. I should mention that I examined several collations...
rouhollah ghasempour
1

votes
0

answer
52

Views

C++ IS there a simplier way to see if a an address region is at least partially interesected with another?

In c++, say I have a ring buffer with addresses. If the consumer is too slow, I want to drop the oldest data. So I have a block of indexes since the production amount may not be equal to the consumption amount. Where A = the head pointer, B = head pointer + new input data size, C = tail pointer - c...
StephanieLoves
1

votes
0

answer
85

Views

Mongodb aggregation too slow in a 3 million entry collection

part of our data is like this... { 'imei': 'LDSJB0005', 'timestamp': '2017-11-11 14:49:26', 'trip_id' : 16, 'data_type': 2, 'longitude': '-', 'latitude': '-', 'loc_wgs84': { 'type': 'Point', 'coordinates': [ 0, 0 ] } } There are 3 million entries like this in db.vehicles and the index is like this....
Junchenj lu
1

votes
0

answer
104

Views

Is there any way I can know creation date of an Index for MongoDB tables(collections)?

Is there any way I can know creation date of an Index for MongoDB tables(collections)? Recently, we saw some indexes which lead to some problem of space and performance and wonder if we can get the timestamp for create_date of the indexes. And I'm not sure if there is a way to do that in the most r...
Tony

View additional questions