indexing

Mongodb text index Duplicate Key Error when part of string field same

一笑奈何 提交于 2020-02-05 08:46:25
问题 For examples: doc1: { 'name':'apple' } doc2: { 'name':'apple juice' } when I create text index with pymongo: db.products_collection.create_index([('name', TEXT)], unique=True, background=True) it give me an error: E11000 duplicate key error collection: c.items_collection index: name_text_alias_text dup key: { : "apple", : 10.5 } Some one know why? I cannot add unique=True for text string? 回答1: A text index splits strings into tokens (words), and those tokens form the keys. So in your example,

Symfony with Zend Lucene and related models (with foreign keys)

有些话、适合烂在心里 提交于 2020-02-05 07:11:30
问题 Well I was developing an application usin Symfony 1.4 and Doctrine when I realized a major drawback on my Zend Lucene implementation. I have a model called Publication that is related (via foreign key relations) with a few other models (subjects, genres, languages, authors, etc.) and I'm getting they're names when adding a new document to the index (using the Jobeet tutorial way) so that I can search for publications with a given subject, genre, language, author, etc... The problem is if for

Java charAt() String index out of range: 5

点点圈 提交于 2020-02-04 08:07:12
问题 I am trying to figure out "what 5-digit number when multiplied by 4 gives you its reverse?" using this code but I get error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 5 at java.lang.String.charAt(String.java:658) at Digits.main(Digits.java:12) public class Digits{ public static void main(String[] args) { int n = 0; int b = 0; String number = Integer.toString(n); String backwards = Integer.toString(b); for (int x = 9999; x < 100000 ; x++ )

Optimize mysql query for date group

微笑、不失礼 提交于 2020-02-04 01:24:13
问题 This my tables: CREATE TABLE IF NOT EXISTS `test_dates` ( `date` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `test_log` ( `id` int(10) unsigned NOT NULL, `timest` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `test_dates` ADD PRIMARY KEY (`date`); ALTER TABLE `test_log` ADD PRIMARY KEY (`id`), ADD KEY `emissione` (`timest`); I have this query to count logs per date: SELECT d.date, COUNT(l.id) FROM test_dates d LEFT JOIN test_log l ON l

iOS Beginner: UIAlertView Window with 3 Buttons > Check what button was pressed

安稳与你 提交于 2020-02-03 04:51:05
问题 I have a working code from a tutorial but don't understand it completely. Situation: After a button was pressed in my iPhone App an AlertView appears with three buttons. Now I like to check what button the user pressed. CODE FROM THE TUTORIAL: - (IBAction)infoButtonPressed:(id)sender { UIAlertView *myAlert1 = [[UIAlertView alloc]initWithTitle:@"My Alert View 1" message:@"Here we go" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Option1", @"Option2", nil]; [alert show]; } -

Postgres multi-column index (integer, boolean, and array)

↘锁芯ラ 提交于 2020-02-02 15:22:35
问题 I have a Postgres 9.4 database with a table like this: | id | other_id | current | dn_ids | rank | |----|----------|---------|---------------------------------------|------| | 1 | 5 | F | {123,234,345,456,111,222,333,444,555} | 1 | | 2 | 7 | F | {123,100,200,900,800,700,600,400,323} | 2 | (update) I already have a couple indexes defined. Here is the CREATE TABLE syntax: CREATE TABLE mytable ( id integer NOT NULL, other_id integer, rank integer, current boolean DEFAULT false, dn_ids integer[]

Postgres multi-column index (integer, boolean, and array)

感情迁移 提交于 2020-02-02 15:19:26
问题 I have a Postgres 9.4 database with a table like this: | id | other_id | current | dn_ids | rank | |----|----------|---------|---------------------------------------|------| | 1 | 5 | F | {123,234,345,456,111,222,333,444,555} | 1 | | 2 | 7 | F | {123,100,200,900,800,700,600,400,323} | 2 | (update) I already have a couple indexes defined. Here is the CREATE TABLE syntax: CREATE TABLE mytable ( id integer NOT NULL, other_id integer, rank integer, current boolean DEFAULT false, dn_ids integer[]

MySql Index Fill Factor?

回眸只為那壹抹淺笑 提交于 2020-02-02 03:46:22
问题 How do you specify the Fill Factor when creating an index in MySql? 回答1: You don't. http://dev.mysql.com/doc/refman/5.0/en/create-index.html However, it is an 'accepted' feature request for version 6.x: http://bugs.mysql.com/bug.php?id=18178 So, don't hold your breath on seeing it any time soon. 回答2: Assuming that you are using InnoDB, it seems like this is only supported at database level, not index level. The setting is called innodb_fill_factor and defaults to 100 see https://dev.mysql.com

Database Case Insensitive Index?

折月煮酒 提交于 2020-02-02 02:43:10
问题 I have a query where I am searching against a string: SELECT county FROM city WHERE UPPER(name) = 'SAN FRANCISCO'; Now, this works fine, but it doesn't scale well, and I need to optimize it. I have found an option along the lines of creating a generated view, or something like that, but I was hoping for a simpler solution using an index. We are using DB2, and I really want to use an expression in an index, but this option seems to only be available on z/OS, however we are running Linux. I

At what level do Postgres index names need to be unique?

跟風遠走 提交于 2020-02-01 10:07:29
问题 In Microsoft SQL Server and MySQL, index names need to unique within the table, but not within the database. This doesn't seem to be the case for PostgreSQL. Here's what I'm doing: I made a copy of a table using CREATE TABLE new_table AS SELECT * FROM old_table etc and need to re-create the indexes. Running a query like CREATE INDEX idx_column_name ON new_table USING GIST(column_name) causes ERROR: relation "idx_column_name" already exists What's going on here? 回答1: Indexes and tables (and