SOLR open search on multiple tables - apache

Say I have authors,publishers,books where authors or publishers may have zero books stored in my DB
how do I index (i.e. config data-congig.xml / schema.xml) my tables so my users can freely type a book title, a publisher or author name and find some results?

1.Make author, publisher, book_title fields in schema and define these filed in qf( query fields) in solr query.
2.You can make a single filed having name of author concatenated with publisher and book title for each book. Make documents book wise. Match searched string in that field it will return all possible results.

Related

Searching a word on all fields of an index with solr 8.9

I'm fetching some datas from a sql database using the DIH of Solr. I created a field all as this :
and I would like to be able to use it to search on all fields thought it. so like if I do he query "John" it would match with a title and a author name.
Actually I have a problem, when I do a query on the all field it only works on a perfect match.
For exemple, if I search name:lub it returns
"name":"CR2/LUB/ Lub oil pump",
"all":["1706443412665794562",
"2165C92A-D107-48A6-A410-08D92AA77517",
"CR2/BER/CRACK/LUB/OT/10-PU-200C",
"CR2/LUB/ Lub oil pump"],
Which is good
But if I search all:lub the response show :
"numFound":0,"start":0,"numFoundExact":true,"docs.
The ultimate goal being to be able to use a word to search on all fields, and to ponderate the weight of the different fields.
Like, if someone search John for books it finds it in the title , and in the author fields (by looking in the all) and then ponderate, by making the title more important and viewing in the response the score of each document
Thanks in advance for your advice!

LINQ to SQL query in related tables

I have a library database with related tables.
dbo.boeken (books) that only have the general data of a book.
PK is BoekID
There is a relationship with dbo.BoekenGegevens (Book data). These data for the book are the author, publisher and nur codes. An author and publisher have written and published several books.
FK is BoekID
(The other FK's belongs to Author / Publisher etc.)
The other table has the details of who owns the book.
FK is BoekID
A book can be owned by several libraries.
Now I want to do a search with a Linq query on the title of a book.
How do I build a LINQ query so that I only see the books that belong to the requesting library?
The Datasets:
Private dbBoeken As New BoekenDataContext
Private dbBoekenGemeenten As New BoekenGemeentenDataContext
Private dbBoekenGegevens As New BoekenGegevensDataContext
Code i use:
Dim searchTitle = From title In dbBoeken.Boekens
Where title.Titel = txtTitle.Text
Join bookid In dbBoekenGegevens.BoekenGegevens On bookid.BoekID Equals title.BoekID
Select title
dbGridView.DataSource = searchTitle
Error when execute the query:
System.InvalidOperationException: The query contains references to items defined in a different data context.

Capturing/scraping book genre information from google

When I search for a book on google (search query: book title + genre e.g. of 'mice and men genre') I get the book genre(s) in a box which is above the search results. Sometimes there are multiple genres and sometimes just the one.
How can I capture this data?
I have a large list of books which I need the Genre information for. Are there any automated methods to gather this data? or alternative sources?

Full text search on normalized database

I have a normalized sql server 2005 database. An example of a table that is something like this:
Location
LocationID,
CustomerID,
OrderID
This is abbreviated. However, the normal query syntax simply uses joins to show the location as city state zip and the name of the customer and so on.
I would like to implement full text search on those values. So if LocationID = 43 which is Phoenix AZ I would like the user to be able to search for 'Phoenix' or 'AZ' and return the associated rows. Similarly, if they search for 'Smith Phoenix' they will get all orders for a customer with a name similar to Smith in Phoenix.
My question is, should I use a View or a UDF to build a table that replaces the value 43 with 'Phoenix AZ'? And implement fulltext search from there?
How do I implement fulltext search on a normalized database?
You need to add the full text index on the table that has the string values. Then use CONTAINS or FREETEXT along with your joins.
Also look into CONTAINSTABLE and FREETEXTTABLE.
http://doc.ddart.net/mssql/sql2000/html/acdata/ac_8_qd_15_1m9f.htm
Honestly, for something like this, I'd use Lucene.NET (assuming a .NET front end, or just Lucene for the back end). While you could search on each of those items, I've found that SQL Server full-text search is more of a pain than it's worth.
With Lucene, you create indexes when you add/edit/delete items in the DB, and then search those indexes (each item is a document with fields which you specify).

What sort of database design would I need to use in case I wanted users to save tags, and be able to call already used tags?

I'm trying to implement a feature similar to StackOverflow's tag feature. That a user can create a new tag, or by typing pull up a list of similar tags already created.
This is such a wonderful feature on this site and I find it sad that most sites do not have something like this. It's both robust, and yet very very flexible and best of all: driven by the community.
So I have these two tables:
Company
id
email
name
companySize
countryOfOrigin
industryid
Industry
id
description
Every time a user writes a new tag, I want to create one with a unique ID, and also be able to search for existing tags.
Will this database design allow for an easy and efficient implementation of this feature?
If not, please give a little guidance. :)
Whilst there's not a tremendous amount of information to go on, what you've listed should be fine. (The 'tag' being the 'description' field in the industry table, etc.)
As you might imagine, all of the real work is done outside of SQL, where you'll need to...
(Potentially) add new tag(s) that don't yet exist.
Associate the industry with the supplied tag(s).
(Potentially) prune previously used tags that may no longer be in use.
...every time you edit an industry.
That said, the key limitation of your proposed setup is that each company can only belong to a single industry. (i.e.: It can only have a single industry tag associated with it.)
As such, you might want to consider a schema along the lines of...
Company
id
...
countryOfOrigin
Industries
id
description
CompanyIndustriesLookup
companyID
industryID
...which would let you associate multiple industries/tags with a given company.
Update...
For example, under this setup, to get all of the tags associated with company ID 1, you'd use...
SELECT Industries.description FROM (CompanyIndustriesLookup, Industries)
WHERE companyID=1 AND industryID=Industries.ID
ORDER BY Industries.description ASC;
On a similar basis, to get all companies tagged with an industry of "testing", you'd use...
SELECT Company.name FROM (Company, Industries, CompanyIndustriesLookup)
WHERE Company.id=CompanyIndustriesLookup.companyID
AND Industries.id=CompanyIndustriesLookup.industryID
AND Industries.description="testing"
ORDER BY Company.name ASC
A very easy (if somewhat suboptimal, but it often does not matter) solution to use tags is to not have tag ids at all. So, you have:
Items
ItemId
Name
Description
...
ItemTag
ItemId
Tag
Adding a tag to an item is just adding the tuple to the ItemTag table, whether the tag already exists or not. And you don't have to do any bookkeeping on removing tags either. Just keep an index on ItemTag.Tag, to be able to quickly display all unique tags.