Sphinxql: several fields matching - sphinx

String with author and his book is given. There are two fields in index: author and title. I need to find all books where author and title matches.
String may contain only author or only title, so I can't parse it. If I search
SELECT id FROM books
WHERE MATCH('#(author, title) "jane smiley horse heaven");
, I don't get the most relevant book with author="jane smiley" and title="horse heaven".
I need something like
SELECT id FROM books
WHERE MATCH('#(title) "horse heaven" #(author) "jane smiley"');
but without splitting the string.
Is it possible?

MATCH('#(author, title) "jane smiley horse heaven"');
is asking for that exact phrase (quotes are phrase operator). ie those four words sequential in the text. As you say that wont really match.
Instead
MATCH('#(author,title) (jane smiley horse heaven)');
should mean it just requires those words. But in any field, and technically in any order (so could match against "jane heaven, horse drawn smiley" or whatever ;)

Related

Significance of entering both title and name while creating a form

While creating a new form,do we need to enter both title and name for the form?may i know why it is mandatory to enter both or what is the difference between Form title and name?
One more thing i noticed is like i can enter same title for multiple forms and is not unique.
The way it was explained to me, and how I have used them, is that the Title is the name of the form, how it is identified to yourself and others. The Name is the roll that it plays. So you might title the form MyDataForm1, but if the form is for the process of payroll analysis, it's name would be PayRollAnalysis1.
I hope I did not misunderstand the nature of the question, but that is how I interpret the answer.

How to store different view in a single Microsoft Word document?

I would like to create an application that allow users to add user-readable text in word document and at the back end maintain complex text (syntax) like MergeField or Velocity code.
e.g. Simple text: Hello Mr. Bob. Complex syntax: Hello «#if($gender == 'Male' Mr. #{else} Ms. #end» Bob
Is this achievable to maintain both simple text view and complex syntax view in single word document?
Thanks
First, you can't have dot in variable name, so let's assume it's saved in $gendervariable.
Second, you can have complex syntax with default of "Hello Mr. Bob" if no gender variable:
Hello #if( $gender == "Female" ) Ms.#{else} Mr.#end Bob
Notice that Mr. is the default text

web2py: customizing form.vars to pass inputs id

I'm building a web app using web2py for attending employees.
this is the db in the model
db.define_table(
'employee',
Field('name'),
format = '%(name)s'
)
db.define_table(
'attendance',
Field('employee_id',db.employee),
Field('attend','boolean'),
Field('comments','text')
)
This is the controller:
employeeIDS=db(db.employee).select(db.employee.ALL)
table=[]
for eid in employeeIDS:
table.append([eid.name,INPUT(_type="checkbox",_name=eid.id,_id=eid.id),INPUT(_type="text",_name="comments",_id=eid.id)])
form=FORM( TABLE(TR("employee name","attended?","comments"),*[TR(*rows) for rows in table]),INPUT(_type="submit",_value="SUBMIT"))
if form.accepts(request,session):
response.flash="form accepted"
print(request.vars)
elif form.errors:
response.flash="form is invalid"
else:
response.flash="please fill the form"
return dict(form=form,vars=form.vars)
My question is this:
How can I access the id of the attend and comments fields in each row to associate these fields with the related employee. So, when I insert the form.vars to the attendance table, I guarantee that each employee recorded as attendance or absence and the related comments will inserted too.
Thanx
Instead of giving each comments input the same name, make the names unique, including the record ID as part of the name:
INPUT(_type="text", _name="comments_%s" % eid.id)
Then you will have form.vars.comments_1, form.vars.comments_2, etc.
As an aside, note that HTML id attributes should be unique, but you are using the value eid.id as the id attribute of both the checkbox input and the comments input.
I think a better choice is to use SQLFROM instead of FORM.
There you can customize the resulting form in the view right the layout you want to, even with HTML helper for tables, you have already used.
Please have a look at the signature of the SQLFORM - it offers a lot options as labels or showid (following the link just scroll down a little).
To exclude a field of being changed or even displayed in the SQLFORM use:
db.my_table.a_field.writable = False
db.my_table.a_field.readable = False
as described here - it's the same for SQLFORMS.

Hide method signatures in Doxygen

I'm trying to document some Java REST interfaces uses Doxygen, similar to this.
The problem I'm having is that I can't remove the method signature from the output, so each section looks like this:
Book com.place.getBook(#QueryParam("title") String title, #QueryParam("author"))
This method returns a book or list of books matching the given title and author.
Parameters:
title - The title of the book
author - The author(s) of the book. Separate multiple authors with commas.
But what I actually want is to display the URL and no method signature:
URL: /services/book?title={title}&author={author}
This method returns a book or list of books matching the given title and author.
Parameters:
title - The title of the book
author - The author(s) of the book. Separate multiple authors with commas.
I think I can add my URL tag using a custom alias, but how do I get rid of the method signature?

Dynamic Reports using SSRS

Let me declare... I am a newbie at this filling in the spot temporarily at the moment.
Problem: Develop a application summary report using SSRS 2008( the completed product should be a RDL file, which can be deployed to the SSRS Server) for the online application completed by the applicant.
A little bit of background: The applicant fills in an online application using our web application, where he completes required and optional fields. The app summary report, is provided to the applicant filling out the application as a summary of his app and should display only the fields completed by the applicant.
Example:
Lest us say John Smith lives at
Add Line 1: 123 Any Street
Add Line 2: Null
City: Some City
State: Some State
And his spouse Jane Smith lives at
Add Line 1: 321 Any other Street
Add Line 2: Apt A
City: Some City
State: Some State
So in the report, the null field (Add Line 2) should not be displayed for john but displayed for Jane. When I say not displayed, meaning, the field label should be hidden the and report should adjust the spacing to not show a skipped blank line in the report.
We have about 1000 such fields that can or cannot be answered by the applicant. So the report should be generic and use as much of inbuilt functionality as possible.
If needed, an Xml containing key value pairs of fields and responses. this Xml can be made so that it can contain all fields and unanswered responses as null or only answered responses. i am not sure how this would help but putting it out there if needed.
I have done simple reports, but i have no idea on how to approach this situation. Any help will be great help.
Thanks.
I have had a similar situation and ended up using this approach within a textbox. Taking your example above, you would have this setup for your fields within the textbox, with the [ ] being fields from the dataset:
Name: [first_name] [m_name] [last_name]
Add Line 1: [address_1]
[expression]City: [city_name]
State: [state_name]
Zip: [zip_code]
Note that the expression and the City have no space between them. What happens is the city will be on its current line when [address_2] is null and move to the next line when there is an address line 2, using this expression:
=IIF(IsNothing(Fields!address_2.Value), "",
“Add Line 2: “ & Fields!address_2.Value & VbCrLF)
When the IFF is true and [address_2] is null the expression will write “” (Nothing) and [city_name] will remain on the same line. When the IFF is false and there is an [address_2] the label “Add Line 2” will be written along with the value of [address_2] and the [city_name] will be moved to the next line by “VbCrLf”. A more robust method that handles if [address-2] has a string of length 0 or a few spaces is this expression:
=IIF(IsNothing(Fields!address_2.Value) OR Len(Trim(Fields!address_2.Value)) < 1, "",
“Add Line 2: “ & Fields!address_2.Value & VbCrLF)
This stops the strange double space when a field is empty but not null; something similar woks great for middle names. Hopefully this is helpful to you or someone else reading this post.
This was really simple...
Lets say we have a report which is in a tabular format using rectangles and textboxes,
--------------------
|FIRST NAME : AAAA |
|LAST NAME : BBBB |
|PHONE: XXX-XXX-XXXX|
--------------------
Use the following expression to control visibility of the controls that you want to hide
=IsNothing(First(Fields!WorkPhoneNumber.Value, "DataSet1"))
Make sure all the controls are of the same height and width. I created a row with just 2 controls (the label text box and the value text box) and set their visibility using the value of the value text box as described in the expression above.
Since the row had just two controls the hiding the would auto adjust the layout as i desired.