Optimizing search query for multiple search criteria [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a search functionality where I have multiple search criteria like State,District,University,Programme,Level,Courses, Institutes etc. This itself makes 7 search criteria.
I can search using any one search criteria or all or any combination. By this I have to check for all the possibility of search i.e. 2^7 combination using IF-ELSEIF loop.
I want to avoid this method of searching since any day if a new criteria comes up that increases the complexity of code by power of 2. Is there any better algorithm which can be useful to tackle this performance issue with my search.
I am implementing the same using PHP-MySQL.
Regards,
Suvojit

Build your $sql string dynamically with where clause created using php implode. Case solved

Related

MongoDB/PHP: search for string with query [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
EDIT: I solved it. Just need to use "MongoDB\BSON\Regex".
I'm storing books as documents in MongoDB, with the individual pages stored as strings in an array. I'm trying to implement a search page that can take a string and return all documents that contain it. Can this be done directly with a MongoDB query called using PHP (i.e searching for a substring within the string arrays)?
I'm using MongoDB\Driver ( http://php.net/manual/en/book.mongodb.php ) because it was the only option that worked on my machine, and I couldn't find detailed documentation or tutorials for this particular driver. Can anyone help?
Something like
db.table.find({"bookTextField": /.*(the string).*/})
EDIT: Of course, replace table by the table name and bookTextField by the field of the table containing the text

How to find popular search from a set of search strings in php? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a data set of searches made on a website. I have to find top searches from that data set. The problem is, i cannot think of a way to do it. The search terms are long sentences. How could i find what are users interested in? It seems to be a problem of counting and i am using php. Any suggestion would be appreciated.
You can create a table in database, which will contain columns search_phrase and counter. Each time when user will search same phrase, you'll just increase counter instead of creating new row.
You can also create a script which will take all records from this table, and find similar phrases.
You can make counter corresponding to each phrase. Suppose You have a queries in long sentence format , divide your sentence into smaller parts and identify the most meaningful word and avoid the conjuctions and other verbs. Particularly focus on Nouns. For an eg, Query is : How to Make account on stackoverflow? Possible Solutions[words] : account, stackoverflow,make. Possibly in this way you can solve it.

how to create a better search algorithm than just simple match and search [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
what algorithm will be best suited for the following situation:
Suppose the user enters in search box :- Dell Computers
But in the database this term doesn't exist but what exist is :- Dell
or just :-Computers
so how/what alogrithm can work for the above scenario.
Steps required:
1) Find to see if an exact match exists for "Dell Computers"
2) If not, then check for each word like "Dell" and "Computers"
Moreover i want to implement this in PHP. Any ideas how to do it?
This has been done extensively in the area of Full text searching. Look at Lucene, ElasticSearch, MySQL Full-Text Search, or PostgreSQL Full Text Search.
The basic idea is to create a trie of single keywords pointing to the resulting set of articles/documents, then look up each word separately and do a set intersection of the results to find articles matching both - and fall back on the individual result sets if there are no good intersections.
Add to that stemming of the lookup words, and you're on your way to reimplementing Lucene and friends.

MySQL Algorithm vs Query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
You find a lot of info on this online. But not what the exact work around of the use of Algorithm is in MySQL. The real basics, if you will..
What a query is, is obvious, of course. What Algorithm does, remains unclear.
Main reason for this question is: to improve profiling & matching records to known users. (In this case: to match docs in a database to users that need them)
Some examples of the usage of it are highly appreciated!
Algorithm is a keyword used with create view in MySQL. The documentation does a pretty good job of explaining it.
The short answer is that MySQL supports two methods of handling views: either "merging" the view definition in the calling code or creating a temporary table. The first is called MERGE and the second TEMPTABLE. In general, MERGE is faster, but most views are TEMPTABLE because of the restrictions on `MERGE.

Symfony 2 search in hundred thousands rows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I search for my website developed under Symfony2, what questioned table database of hundreds of thousands of lines 2 columns.
Currently I use FULLIndex and like it, but it takes forever to respond, as this search engine is the very keystone of the site.
It therefore I need a strategy to implement, technical or network to optimize this search on this table and others as large and multiple columns.
Thank you in advance !
If you have a big database and you want to search data in it, I definitely recommend you ElasticSearch
There is a good bundle for this here.
This bundle is maintained by FOS. It's very easy to make it work in a symfony2 project

Categories