Order by relevance, lucene search - solr

Search Term:
cristina de oliveira
This is the query:
(name_text:(cristina\ de\ oliveira^200.0 OR cristina\ de\ oliveira*^100.0 OR cristina\ de\ oliveira~^50.0))
This is the result:
MARIA CRISTINA DE OLIVEIRA,
LIA CRISTINA DE OLIVEIRA,
MARISA CRISTINA DE OLIVEIRA,
CRISTINA de OLIVEIRA
Problem:
Since search term is "cristina de olveira", the first result should be "CRISTINA de OLIVEIRA" and not "MARIA CRISTINA DE OLIVEIRA", how can I get exactly search term as the first result

Related

Query a nested dictionnary in MongoDB document

I'm trying to learn how to filter out nested dictionaries in the MongoDB database. All documents have the same structure as this example which I will try to get:
I try to obtain the document thanks to the Name which is 'My Burberry - Eau de Parfum':
{ "q0.Results": {"Name":"My Burberry - Eau de Parfum"} }
But it doesn't give me anything back:
What you are doing:
{ "q0.Results": {"Name":"My Burberry - Eau de Parfum"} }
says find me documents where q0.Results is exactly like this document/subdocument: {"Name":"My Burberry - Eau de Parfum"}
In the arrays, you just need dot notation and the following should give you the result:
{ "q0.Results.Name": "My Burberry - Eau de Parfum" }

How to split a string considering more than one blank spaces in Ruby

I'm trying to get an array with the following output:
["", "7", "02156567848", "CORTIER EP. ENGERANT ROSE JOSE MARIE", "059 NOMBRE DE LA PERSONA ES DIFERENTE"]
But using next code the result is different, because split is considering any non word character to separate the strings.
a = " 7 02156567848 CORTIER EP. ENGERANT ROSE JOSE MARIE. 059 NOMBRE DE LA PERSONA ES DIFERENTE"
b = a.split(/\W\W+/)
p b
Output:
["", "7", "02156567848", "CORTIER EP", "ENGERANT ROSE JOSE MARIE", "059 NOMBRE DE LA PERSONA ES DIFERENTE"]
Any idea how to solve this?
Thanks and regards!
Split on \s{2,} -- two or more white-space characters.
a = " 7 02156567848 CORTIER EP. ENGERANT ROSE JOSE MARIE. 059 NOMBRE DE LA PERSONA ES DIFERENTE"
a.split(/\s{2,}/)
# => ["", "7", "02156567848", "CORTIER EP. ENGERANT ROSE JOSE MARIE.", "059 NOMBRE DE LA PERSONA ES DIFERENTE"]
repl

extjs - Placeholders in strings

I saw here in the doc that there is a placeholder notation like:
"El valor mínimo para este campo es de {0}"
But I didn't find the function that will do the replacement. I expect a function similar to sprintf in php to exist which allow to replace these strings like:
function_Im_looking_for("El valor mínimo para este campo es de {0}", 10);
that returns the string "El valor mínimo para este campo es de 10".
How can that replacement be achieved.
Ext.String.format('Hello {0}', 'Foo');
It's worth noting that it doesn't attempt to do any formatting, just simple replacement. So you can't do something like {0:d/m/Y}

How i get the similarity of phrases in C# .NET

I have a sql database with data about headers of news. Example:
id title
867 MPE consegue inverter julgamento
868 Defensoria P blica realiza licita
869 Prefeitos eleitos de todas as partes do Estado
870 Inc ndio deixa 80 pessoas desabrigadas
871 Carlos Amastha visita parlamentares
872 Defensoria P blica requer anula o
873 Marcelo Miranda diz que n o possui obriga o
874 Ex-assessor diz que Coimbra lhe deu dois cheques
I need to get each title and see if there are other news to talk about the same subject.
How i do it? My plataform is .Net and use sql server 2012.
You will probably want to put a Full-Text Index on this column and/or table. It's a complex subject, but you can start reading up on it here: http://msdn.microsoft.com/en-us/library/ms142571.aspx

Sorting a PHP associative array

I would like my associative array to have its elements sorted. Currently, my array is like:
Array
(
[1585] => Chicago, Ohio,Dallas, Denver, Detroit, Houston, Las Vegas, So. Calf.
[1586] => Chicago, Ohio, Dallas, Denver, Houston, Las Vegas, So. Calf.
[1588] => The Bay Area, Chicago, Dallas, Detroit, Houston, Las Vegas, Minneapolis
[1589] => Charlotte, Chicago, Ohio, D.C.
[1590] => Orange County, Orlando, Philadelphia, Phoenix, Richmond, San Diego, The Bay Area, Seattle
)
Whereas I would like this array to be in ascending order like this:
Array
(
[1585] => Chicago, Dallas, Denver, Detroit,Houston, Las Vegas, Ohio, So. Calf.
[1586] => Chicago, Dallas, Denver, Houston, Las Vegas,, Ohio, So. Calf.
[1588] => Chicago, Dallas, Detroit, Houston, Las Vegas, Minneapolis, The Bay Area
[1589] => Charlotte, Chicago, D.C., Ohio
[1590] => Orange County, Orlando,Philadelphia, Phoenix, Richmond,San Diego, Seattle, The Bay Area
)
Thanks ....
You need to loop over each element explode on the , to get a list you can actually sort. then you can use a sort function on the list and implode back to , separation. For example:
foreach($arr as $id => $list){
$listArr = explode(',', $list);
sort($listArr);
$arr[$id] = implode(', ', $listArr);
}
This is just a simple example. Depending on the format and consistency of the separation of items in the string you may have to add in some trimming or use preg_split instead of explode but that should give you the basic idea.

Resources