Use full name as one word using Google Custom Search - google-api

I have a list of 14 keywords, as well as the name. I need to send a request through the Custom Search JSON API by building the following query:
"name * keyword1" OR "name * keyword2" OR "name * keyword3" OR ...
If the name consists of only one word, then the request does not exceed the limit of 32 words (which is set in the api), but if it contains more than one word (for example, John Smit), then the limit is exceeded and the result becomes incorrect. Is there any way to force the search to accept the name as a single word?
Or maybe it's worth somehow building a different query? For example something like this:
"name" AND "keyword1" OR "keyword2" OR "keyword3" OR ...
Then there will be 32 - 14 = 18 words left, which should be enough for the name.

Yes, it turned out that everything can be solved by changing the query. The final request looks something like this:
"name" AND ("keyword1" OR "keyword2" OR "keyword3" OR ...)

Related

How to use the PubMed API to search for an article with an exact title?

I'm trying to use the PubMed API to search for articles with an exact title. As an example, I want to search for the title: The cost-effectiveness of mirtazapine versus paroxetine in treating people with depression in primary care.
I want up to 1000 results in JSON format, so I know that the first part of my URL should look like this:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=
How do I add a title search as a GET parameter?
I've been using the Pubmed advanced search constructor, and that suggests that the query should look like The cost-effectiveness of mirtazapine versus paroxetine in treating people with depression in primary care[Title].
But if I try just adding that to the URL term=, PubMed tries to break down the title into all kinds of peculiar queries:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=The%20cost-effectiveness%20of%20mirtazapine%20versus%20paroxetine%20in%20treating%20people%20with%20depression%20in%20primary%20care[Title]
How can I specify an exact title as a GET param?
Use field=title
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=The%20cost-effectiveness%20of%20mirtazapine%20versus%20paroxetine%20in%20treating%20people%20with%20depression%20in%20primary%20care&field=title
Check out ESearch API for more information:
http://www.ncbi.nlm.nih.gov/books/NBK25499/#_chapter4_ESearch_
Use + instead of %20 (space).
For example:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=1000&term=cost+effectiveness+of+mirtazapine[title]

Wiktionary/MediaWiki Search & Suffix Filtering

I'm building an application that will hopefully use Wiktionary words and definitions as a data source. In my queries, I'd like to be able to search for all Wiktionary entries that are similar to user provided terms in either the title or definition, but also have titles ending with a specified suffix (or one of a set of suffixes).
For example, I want to find all Wiktionary entries that contain the words "large dog", like this:
https://en.wiktionary.org/w/api.php?action=query&list=search&srsearch=large%20dog
But further filter the results to only contain entries with titles ending with "d". So in that example, "boarhound", "Saint Bernard", and "unleashed" would be returned.
Is this possible with the MediaWiki search API? Do you have any recommendations?
This is mostly possible with ElasticSearch/CirrusSearch, but disabled for performance reasons. You can still use it on your wiki, or attempt smart search queries.
Usually for Wiktionary I use yanker, which can access the page table of the database. Your example (one-letter suffix) would be huge, but for instance .*hound$ finds:
Afghan_hound
Bavarian_mountain_hound
Foxhound
Irish_Wolfhound
Mahound
Otterhound
Russian_Wolfhound
Scottish_Deerhound
Tripehound
basset_hound
bearhound
black_horehound
bloodhound
boarhound
bookhound
boozehound
buckhound
chowhound
coon_hound
coonhound
covert-hound
covert_hound
coverthound
deerhound
double-nosed_andean_tiger_hound
elkhound
foxhound
gazehound
gorehound
grayhound
greyhound
harehound
heckhound
hell-hound
hell_hound
hellhound
hoarhound
horehound
hound
limehound
lyam-hound
minkhound
newshound
nursehound
otterhound
powder_hound
powderhound
publicity-hound
publicity_hound
rock_hound
rockhound
scent_hound
scenthound
shag-hound
sighthound
sleuth-hound
sleuthhound
slot-hound
slowhound
sluthhound
smooth_hound
smoothhound
smuthound
staghound
war_hound
whorehound
wolfhound

Logic for parsing names

I am wanting to solve this problem, but am kind of unsure how to correctly structure the logic for doing this. I am given a list of user names and I am told to find an extracted name for that. So, for example, I'll see a list of user names such as this:
jason
dooley
smith
rob.smith
kristi.bailey
kristi.betty.bailey
kristi.b.bailey
robertvolk
robvolk
k.b.dula
kristidula
kristibettydula
kristibdula
kdula
kbdula
alexanderson
caesardv
joseluis.lopez
jbpritzker
jean-luc.vey
dvandewal
malami
jgarciathome
christophertroethlisberger
How can I then turn each user name into an extracted name? The only parameter I am given is that every user name is guaranteed to have at least a partial person's name.
So for example, kristi.bailey would be turned into "Kristi Bailey"
alexanderson would be turned into "Alex Anderson"
So, the pattern I see is that, if I see a period I will turn that into two strings (possibly a first and last name). If I see three periods then it will be first, middle. The problem I am having trouble finding the logic for is when the name is just clumped up together like alexanderson or jgarciathome. How can I turn that into an extracted name? I was thinking of doing something like if I see 2 consonants and a vowel in a row I would separate the names, but I don't think that'll work.
Any ideas?
I'd use a string.StartsWith method and a string.EndsWith method and determine the maximum overlap on each. As long as it's more than 2 characters, call that the common name. Sort them into buckets based on the common name. It's a naive implementation, but it that's where I'd start.
Example:
string name1 = "kristi.bailey";
string name2 = "kristi.betty.bailey";
// We've got a 6 character overlap for first name:
name2.StartsWith(name1.Substring(0,6)) // this is true
// We've got a 6 character overlap for last name:
name2.EndsWith(name1.Substring(7)) // this is true
HTH!

FTsearch did not work correct in xpage's view control

I have a view control and make the query string by the search param from the application layout control.Full text index is already enabled, the code in the search property like below:
var queryStr="";
if(param.option=="byName"){
queryStr="[name]="+param.search;
}
else{
queryStr="[title]="+param.search;
}
return queryStr;
i found that the queryStr can be made correct,like "[name]=Vincent",but the view shows all documents contain the word "Vincent",not only the spesific field "name". Just like I used "Vincent" for search.
I want to know how to get the correct result.thank you!
Should it be?
"[name] CONTAINS "+param.search;
similar to this:
[Projectname] CONTAINS top secret
Use the word CONTAINS rather then = ?
I'm not 100% sure but there was a recent blog post on seaching just the other day: http://lostinxpages.com/2014/05/15/exporting-to-excel-using-queries-in-xpages/
Finally I find the problem. The full-text syntax works fine, both "field/FIELD/[]" or "contains/CONTAINS/=" can work. But I used an application layout for search. The search button generate two parameters: "option"(if you choosed before) and "search" by default. The search parameter is used as the value of the view control's search property directly. When I customed this property by myself ,it would not be used(if the ssjs return a null) or generate an " not understandable" error(if the ssjs return a string,which is normal in most situation). The solution is give that two parameters custom parameter name .like fieldName for option, searchText for search. After that, you can use param.fieldName and param.searchText to build your full-text search string.I have tried ,and it works fine now.
For the most part David Leedys answer should work. Some pointers on diagnosing FTI issues though.
1. Your search phrase must be surrounded by quotes. Example:
queryStr='[name] = "' + param.search + '"';
2. Get the actual fully constructed search string and test it in the Notes FTI search bar. Do you get the same incorrect results? If so, then fix the search string.
3. If it is working in the Notes client then add the following debug to the Domino servers notes.ini file (alternatively: set config from console).
Debug_FTV_Search=1
When you run a search it should generate debug like this: Search [name] CONTAINS "String"
IN FTGSearch
[22E8:008A-1710] option = 0x400219
[22E8:008A-1710] Query: ( FIELD name CONTAINS "String")
[22E8:008A-1710] Engine Query: ("String"%STEM#F134)
[22E8:008A-1710] GTR query performed in 10 ms. 2 documents found
[22E8:008A-1710] 0 documents disualified by deletion
[22E8:008A-1710] 0 documents disqualified by ACL
[22E8:008A-1710] 0 documents disqualified by IDTable
[22E8:008A-1710] 0 documents disqualified by NIF
[22E8:008A-1710] Results marshalled in 8 ms. 2 documents left
[22E8:008A-1710] OUT FTGSearch error = 0
[22E8:008A-1710] FTGSearch: found=2, returned=2, start=0, count=0, limit=0
[22E8:008A-1710] Total search time 22 ms.
You want to check the Query and Engine Query from client search vs XPage to see what is generated. If they don't match, update your question with the results so we can see what's going on.
The disqualified section tells you if search results were dropped. For example, if your XPage was running under credentials that were not allowed to view the documents, then disqualified by ACL would have a value.
4. The Notes client has two search syntax methods. There is "Notes" and "Web" style. By default for R9 (and R8.x IIRC) is Web style (client). The server uses Notes style.
You can change the client behavior in the Basic Settings preferences.
The Web style does not understand Notes syntax unless the first word in the search is a reserved keyword and all in uppercase.
Example.
Will use "web" search: field name contains "string"
Will use "Notes" search: FIELD name contains "string"
I am not sure if that impacts XPiNC though (never tested it).

Dynamic number of evaluations on a where (lambda)

I'm new to Entity Framework, LINQ and lambda expressions. I need to do a search over a user's table, and I need to emulate one that already exists on a desktop application. This search gives only 1 text field, and then it takes anything that you put in it and creates a "contains" query on different users' attributes like name, last name, username, etc. The most important part is that if you put two or more words in then the search makes the query search for different words.
Example:
If I search for "ju pe" I will get "Perez, Juan", this works by the identification of blank spaces.
Using regular SQL I can build a regular string containing the query, but how can I do that using lambda?
In other words, how can I get a dynamic number of "evaluations" on the .where()? Like .Where(EV1 || EV2 || EVn)
There is neat library called LinqKit which contains predicatebuilder
Sample code:
var predicate = PredicateBuilder.True <User> ();
predicate = predicate.Or(x => x.Name.Contains("ju"));
predicate = predicate.Or(x => x.Name.Contains("pe"));
// etc ...
Users.AsExpandable().Where(predicate);
You can and/or as much as you like.
You can do this using simple Linq by building a complex Where predicate, if I understand you correctly. Please let me know if I misunderstood you! Let's say you have a string searchTermInput and users, an IEnumerable<User> for some type User with a Name string property. Then you can write:
users.Where(user => searchTermInput.Split(' ')
.All(searchTerm => user.Name.Contains(searchTerm)));
In other words: for each user, check if that user's name contains every one of the search terms and filter it out if it does not.

Resources