Index & in Sphinx? - exception

I keep adding to my exceptions.txt file in m Sphinx configuration for acornyms that contain & e.g:
A&E => A&E
so that it is not indexed as two separate letters. However it is getting monotonous and I wonder if I can/should somehow just make '&' indexed. The questions are:
How do I force & to index
Will A&E then index as such?
Is there a downside I'm not 'getting' since Sphinx decides to not index & in the first place?

Add & to charset_table
http://sphinxsearch.com/docs/current/conf-charset-table.html
should do
There is a small chance of things like 'marks&spensors' means that would only ever match that exact form (ie wouldnt match say marks & spensors as different.
Might want to consider
http://sphinxsearch.com/docs/current/conf-blend-chars.html
instead, so get somewhat best of both.

Related

Adding the info from one text field into another without erasing the info that already exists

I have an access database with two Long Text fields "QAComment" and "NoteComment." We have found that the NoteComment field is rarely used and we want to stop using it, placing the information that might go there within the QAComment Field instead. Every record currently has text in the QAComment field already. What I am trying to do is run an update query that moves the information from NoteComment and appends it onto the Information from QAComment - I cant lose whats already in there. I tried googling for a way to do this but it keeps sending me to basic update queries where the info would get replaced, not added onto. I thought it might be possible to concatenate the two fields together into a third field and then copy that info back to the QAComment field, using
Conc: [QAComment] & " " & "Note comments:" & " " & [Notecomment]
Which works, but I can't figure out how then to use that expression to record that information into the table. I thought I might be able to use the value of the concatenate in the Update, but I cant seem to figure out how to reference it. I also tried just putting the Conc statement in the Update To: but nothing seemed to happen. I'd appreciate anyone who can think of a way to do this.
Sounds like you're building the query in Design View. Switch to SQL View and paste in this text, substituting your table name in place of YourTable
UPDATE YourTable AS y
SET y.QAComment = y.QAComment & " Note comments: " & y.Notecomment
WHERE Len(Trim(y.Notecomment)) > 0;
You can switch back to Design View, if desired, to see how the query is presented there.

Overlap of unique Identifiers when trying to pull/expand data

LoadTableQuery.Qry = #"
SELECT `orders`.`ordID`,
`orders`.`OrderType`,
`prt`.`Name`,
`orders`.`prtID`,
`orders`.`ReqRef`,
`orders`.`DateOrdered`,
`orders`.`orderETA`,
`orders`.`DateRcvd`,
`orders`.`Status`,
`orders`.`ShipCost`,
`orders`.`Duties`,
`orders`.`Currency`,
`orders`.`Conv`,
`orders`.`Terms`,
`orders`.`Shipping`,
`orders`.`BuyerID`,
`orders`.`ShipTo`,
`orders`.`Notes2`,
`orders`.`Notes3`,
`orders`.`legacyID`,
`prt`.`Address`,
`prt`.`City`,
`prt`.`StateProv`,
`prt`.`PostalZip`,
`prt`.`Tel`,
`prt`.`Contact`,
`prt`.`Email`,
`prt`.`OrderTaxPc`
FROM `n2000`.`orders` left join `n2000`.`prt`
on (orders.prtID = prt.prtID)
prtID is a unique identifier which I'm using to pull the data I need about the party (their name, address, city..). The way it's written above works, accomplishing what I need it to do. getting and inserting the data into my table.
The issue is, I need a SECOND set of party data, based on orders.ShipTo instead of orders.prtID . ShipTo is really just a different prtID.
I'd like to be able to just run it again with
on (orders.ShipTo = prt.prtID).
I've tried using UNION, but that creates a new row, instead of adding columns to my current row. Which is where I'm looking to pull my data from.
The best way to understand it is, I've expanded prtID to add the Name, Address, City.. column data. I'd like to expand ShipTo as well. I don't know how to do that though without simply overwriting the prtID expansion.
The solution was actually quite simple. Hope this helps someone else
Solution
The solution was actually quite simple. Alias the different tables and do a double left join
Solution

Reshape the dataset into more relational format (Transpose SOME rows and assign them to a data subset)

I have a spreadsheet/csv:
Code:,101,Course Description:,"Introduction to Rocket Science",
Student Name,Lecture Hours,Labs Hours,Test Score,Status
John Galt,48,120,4.7,Passed
James Taggart,50,120,4.9,Passed
...
I need to reshape it to the following view:
Code:,Course Description:,Students,Lecture Hours,Labs Hours,Average Test Score,Teaching Staff
101,"Introduction to Rocket Science",John Galt,48,120,4.7,Passed
101,"Introduction to Rocket Science",James Taggart,50,120,4.9,Passed
...
Beleive it or not, can not get the right idea how to do that despite it seems to be very primitive transformation, is there any silver bullet for this?
Original records (csv) have in a way json-like structure so my first approach was to represent the original data as a vector and then transpose it, (but in this case my resulting table looks like sparced matrix - rows I have transpored are blank in the rest of its values)
Another way Im considering - **serialize it into jsons and then de-serialize** into new spreadsheet (jsonize()) - in this case, Im having problems with merging them properly.
In both ways I have it "half-working";
Can anyone suggest simple and reliable algorithm for this;
Any language, RegEx, any tools, code snippets are very appreciated
Assuming that the pattern you've described here is consistent throughout, there are quite a few different approaches you could take I think, but in all cases you basically can use that fact that the 'Course' rows start with "Code:" but that's never going to be a student name.
You can take advantage of this either by a regular expression find/replace, or within OpenRefine.
Example:
Open file in a text editor that supports regular expressions in
find/replace
Search for lines starting with 'Code:' and add additional commas to the start of the row to shift the course data columns to the
right e.g. search for: ^Code: replace with: ,,,,,^Code:
If you now import the file into OpenRefine then you'll have a project with 10 columns (the 10th col is caused by the trailing
comma at the end of the course data row)
You can now use Transpose (or just rename) on the right-most columns which contain the course data, while leaving the left-most
columns which contain the student details
Isolate the rows that contain the phrase 'Student Name' in the first column and remove them (via a filter or facet)
Move the Course Code/Description columns to the beginning of the project, and use the 'Edit Cells->Fill Down' option on each column to get the values repeated on all the relevant lines
Finally rename the columns as you want, remove any extraneous columns

compile error invalid outside procedure

I have a table in my Access database where I keep track of my jobs. I have a form based on a query based on this table. In my table there is a field called [file_path]. This is a field that controls a web browser on my form.
I would like this field [File_path]to be updated when I update my field [customer_Id] on the form. It should be updated to reflect the customer name together with the file path e.g. C:\Users\Windows8\Documents\Projects\Doe John.
How do I pull the [Customers]![Last_Name] and [Customers]![first_name] into my string in field [file_path]?
I think that I have to use VBA code, but not sure how. I have started with this:
Private Sub Customer_AfterUpdate()
Me.File_path = Me.Last_Name
End Sub
I know that this is a feeble beginning. Does someone know how to help me? Please tell me if my question is not clear.
Beside all this the above code is returning Invalid outside procedure in Private Sub Customer_AfterUpdate(). Why?
Me refers to the form. You are correct that using Me is best practice (speed, ease of coding, etc.), but when I was starting out or even now in a complicated application I like to write it out, because that reminds me not to make little mistakes like this. Or, maybe your memory is better than mine, in which case ignore and read on.
[file_path] is in the table, so you need to access it in the table. Your code looks for it in the form, and realizes that it isn't inside Me, and throws this error.
I am going to give you a line of code below that should be a good starting point for you, but I think you may need to examine your calling event. AfterUpdate is cool, because it just seems to happen automatically, but I don't think you want your field updated every single time anything in the whole "Customer" form is updated. If there is a specific textbox that is always updated last (last_name?), you could try that one instead, but I would be nervous about trying to remember to always make sure that was the last one that I updated... I mean, if one day I accidentally did the name before the customer_id, I would have some serious confusion on my hands later on. Might I suggest a command button, and using the Click event instead?
No matter what event you end up using, you really only need one line of code inside your event. There are plenty of ways of doing this. Might I suggest something along the lines of CurrentDb.Execute "update " & myAwesomeTableNameHere & " set file_path='"C:\Users\Windows8\Documents\Projects\" & forms("customers").controls("last_name").text & " " & forms("customers").controls("first_name").text & "' where customer_id='" & forms("customers").controls("customer_id").text & "'"
Now, a caution: data is precious, and beautiful. The names of the people who pay you are even more so. Changing data in a pre-populated table by free-typing into a textbox on a form sounds like disaster waiting to happen to me. If it were me, I would either 1)make backups very often (easist), or 2)validate your entries multiple ways before writing anything to the table.

Find column values that are a start string of given string.

I have a database table that contains URLs in a column. I want to show certain data depending on what page the user is on, defaulting to a 'parent' page if not a direct match. How can I find the columns where the value is part of the submitted URL?
Eg. I have www.example.com/foo/bar/baz/here.html; I would expect to see (after sorting on length of column value):
www.example.com/foo/bar/baz/here.html
www.example.com/foo/bar/baz
www.example.com/foo/bar
www.example.com/foo
www.example.com
if all those URLs are in the table of course.
Is there a built in function or would I need to create a procedure? Googling kept getting me to LIKE and REGEXP, which is not what I need. I figured that a single query would be much more efficient than chopping the URL and making multiple queries (the URLs could potentially contain many path components).
Simple turn around the "Like" operator:
SELECT * FROM urls WHERE "www.example.com/foo/bar/baz/here.html" LIKE CONCAT(url, "%");
http://sqlfiddle.com/#!2/ef6ee/1