We have a table that contains a user's email address, their first name and last name and some date columns. The standard search works great for those.
I would like to provide a way of the user being searchable by their user id which is a GUID. The user id is not a visible piece of data. This search would really only be used by admins
I know I could use the data-search attribute on the user name column e.g.
data-search="43b30438-e3c8-4e27-8b31-5fcc52e53a3b me#test.com"
However that makes that row and any other row findable with just the number "43" as that GUID starts with 43 or "52" because it has a 5 followed by an 2. That is clearly not what I want. How do I make the users searchable by their GUID as well as their username but in the case of the GUID only when it is the whole GUID being searched for?
Thanks
Related
I am working on a piece of my app where the client is wanting the ability for user searches to be saved (these searches are completed by the user completing a set of dropdowns and then entering in a value in an input field).
I was curious to know if the use for an HSTORE could be beneficial here or should I just simply save out each piece of the search?
For Example (from a UI perspective):
User Selects a category, the next select is populated with stats tied to the selected category, the next select drop down is displayed which allows the user to select a predicate (greater than, less than, equal to, not equal to, etc) and then the input field is shown where the user can enter in their value they are searching for. If the user would like to add another search filter, they can click a button and then the user follows the same pattern as the first
The server side params look like this:
Parameters: {"utf8"=>"✓","authenticity_token"=>"FCvOdXuxtEhEchwDn8U2yaEPShfHW2VosgSoR8eSzV8=", "refresh"=>"1", "search"=>{"0"=>{"category"=>"1", "stat_type_id"=>"5", "predicate"=>"Greater Than", "q"=>"200", "type"=>"stat"}}, "unselected"=>""}
These searches won't really be updated, when a user enters in a new search, it will be saved explicitly.
Once we figure out the best route for this project, I will post the code as the answer
I'm making a game involving the user's contacts, but need a way to uniquely identify each contact. This is because the user can easily change the name, phone number, or other property of a given contact. Is there a way to do this?
You can use ABRecordGetRecordID() to get the unique ID of a record. It returns an ABRecordID which is a typedef for int32_t.
ABRecordGetRecordID() is the API that you can use. However, apple documentation does states some noteworthy points about the ABRecordID returned by this API.
Every record in the Address Book database has a unique record identifier. This identifier always refers to the same record, unless that record is deleted or the data is reset. Record identifiers can be safely passed between threads. They are not guaranteed to remain the same across devices.
The suggested method as per apple guidelines is
The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.
In my app, I am also checking for creation date of the contact since the name against the ABRecordID could have been changed by the user. Creation date of a contact DOES NOT change upon device reset.
Though I have pasted most of the content here, its always advised to read the documentation
I am working on an auto complete solution with lucene. Do I need to call the PrefixQuery each time for each field I want to search on? Also, what if I only want to search a small set of items based off another filed's ID?
For example: Let's say I have a list of users that I have indexed. Those users belong to a specific project. I only want to PrefixQuery search users that are on, say, projectId 1.
Assuming your schema has fields "projectid" and "name", you would query for documents (users) matching the query:
+projectid:1 +name:prefix*
where 1 is the projectid and "prefix" is the name prefix you want to search for.
Each contact in the address book, has a unique Id,
1) will this Id ever change? if so when does it change? ie a user deletes a contact, will the other contact id change? how do we make sure of this? will not change now or in the future.
EDIT: would like to uniquely identify a contact, which id should I use as a reference?
The documentation says:
The recommended way to keep a
long-term reference to a particular
record is to store the first and last
name, or a hash of the first and last
name, in addition to the identifier.
When you look up a record by ID,
compare the record’s name to your
stored name. If they don’t match, use
the stored name to find the record,
and store the new ID for the record.
Have one unique field like contact or address and compare the record's name with that field as well as id.
I'm developing a website with a custom search function and I want to collect statistics on what the users search for.
It is not a full text search of the website content, but rather a search for companies with search modes like:
by company name
by area code
by provided services
...
How to design the database for storing statistics about the searches?
What information is most relevant and how should I query for them?
Well, it's dependent on how the different search modes work, but generally I would say that a table with 3 columns would work:
SearchType SearchValue Count
Whenever someone does a search, say they search for "Company Name: Initech", first query to see if there are any rows in the table with SearchType = "Company Name" (or whatever enum/id value you've given this search type) and SearchValue = "Initech". If there is already a row for this, UPDATE the row by incrementing the Count column. If there is not already a row for this search, insert a new one with a Count of 1.
By doing this, you'll have a fair amount of flexibility for querying it later. You can figure out what the most popular searches for each type are:
... ORDER BY Count DESC WHERE SearchType = 'Some Search Type'
You can figure out the most popular search types:
... GROUP BY SearchType ORDER BY SUM(Count) DESC
Etc.
This is a pretty general question but here's what I would do:
Option 1
If you want to strictly separate all three search types, then create a table for each. For company name, you could simply store the CompanyID (assuming your website is maintaining a list of companies) and a search count. For area code, store the area code and a search count. If the area code doesn't exist, insert it. Provided services is most dependent on your setup. The most general way would be to store key words and a search count, again inserting if not already there.
Optionally, you could store search date information as well. As an example, you'd have a table with Provided Services Keyword and a unique ID. You'd have another table with an FK to that ID and a SearchDate. That way you could make sense of the data over time while minimizing storage.
Option 2
Treat all searches the same. One table with a Keyword column and a count column, incorporating SearchDate if needed.
You may want to check this:
http://www.microsoft.com/sqlserver/2005/en/us/express-starter-schemas.aspx